Problem mit wx.Notebook
Verfasst: Freitag 22. Januar 2010, 19:49
Hallo,
ich habe eine Frage zu wx.Notebook. Hier meine Klasse MplPanel:
Und dann habe ich noch meinen Haupt-Frame:
Und jetzt kommt das Problem. Wenn ich auf der Seite mit dem Graph (page_graph), meinen Plot machen will, bekomme ich das nicht hin. Die auskommentierte Zeile 40 ist aus einer älteren Programmversion (ohne wx.Notebook). Und Zeile 41 funktioniert nicht. Fehelrmeldung lautet: Unhandled Attribute Error: 'Notebook' object attribute has no attribute 'page_graph'.
Ich habe schon viel probiert, aber ich glaube ich mache da einen grundsätzlichen Fehler, nur welcher ist es?
Danke für Eure Tipps.
Grüße,
Sebi
ich habe eine Frage zu wx.Notebook. Hier meine Klasse MplPanel:
Code: Alles auswählen
class MplPanel(wx.Panel):
def __init__(self, parent, *args, **kwds):
wx.Panel.__init__(self, parent, *args, **kwds)
...
self.canvas = FigureCanvas(self, wx.ID_ANY, self.figure)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.EXPAND)
self.toolbar = NavigationToolbar2Wx(self.canvas)
self.toolbar.Realize()
self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
self.toolbar.Show()
self.SetSizer(self.sizer)
self.Fit()
Code: Alles auswählen
class MplFrame(wx.Frame):
def __init__(self, *args, **kwds):
kwds["style"] = wx.CAPTION|wx.CLOSE_BOX|wx.MINIMIZE_BOX|wx.MAXIMIZE|wx.MAXIMIZE_BOX|wx.SYSTEM_MENU|wx.RESIZE_BORDER|wx.FULL_REPAINT_ON_RESIZE|wx.CLIP_CHILDREN
wx.Frame.__init__(self, *args, **kwds)
self.createMenuBar()
self.MplFrame_statusbar = self.CreateStatusBar(1, 0)
p = wx.Panel(self)
self.nb = wx.Notebook(p)
page_graph = MplPanel(self.nb)
page_abs = Page_Abs(self.nb)
page_flu = Page_Flu(self.nb)
# add the pages to the notebook with the label to show on the tab
self.nb.AddPage(page_graph, "Graph")
self.nb.AddPage(page_abs, "Abs")
self.nb.AddPage(page_flu, "Flu")
self.SetTitle("Test")
self.SetSize((1000, 700))
self.MplFrame_statusbar.SetStatusWidths([-1])
MplFrame_statusbar_fields = ["MplFrame_statusbar"]
for i in range(len(MplFrame_statusbar_fields)):
self.MplFrame_statusbar.SetStatusText(MplFrame_statusbar_fields[i], i)
mplsizer1 = wx.BoxSizer(wx.VERTICAL)
mplsizer1.Add(self.nb, 1, wx.ALL|wx.EXPAND, 0)
self.SetSizer(mplsizer1)
self.Layout()
...
def OnLoadAbs(self, event):
dlg = wx.FileDialog(self, "Choose Dye Absorption Spectra", os.getcwd(), "", "*.abs*", wx.OPEN)
if dlg.ShowModal() == wx.ID_OK:
pathabs = dlg.GetPath()
mypathabs = os.path.basename(pathabs)
self.SetStatusText("Selected Absorbtion Spectra: %s" % mypathabs)
abs = np.loadtxt(pathabs)
abs = normspec(abs)
#self.gabs, = self.mplpanel.axes.plot(abs[:,0],abs[:,1],'k-', lw=2,label = mypathabs)
self.gabs, = self.nb.page_graph.axes.plot(abs[:,0],abs[:,1],'k-', lw=2,label = mypathabs)
AdjustDisplay(self)
self.ToggleItem(event, 2)
if self.DisplayData == True:
fc = "black"
self.ShowSpectralData(event, pathabs, abs, fc)
dlg.Destroy()
Ich habe schon viel probiert, aber ich glaube ich mache da einen grundsätzlichen Fehler, nur welcher ist es?
Danke für Eure Tipps.
Grüße,
Sebi