I tweaked my code based on the AUI demo so I create the panel with a def
inside the AuiFrame (I iused to have a seperate class fot that ...)
The panel is created and added as tab to the notebook sccessfully.
But when I bind the button on the new tab (the pane) to a function of
the AuiFrame
This function is ececuted right away and then breaks with an assertion
error.
So: how do i bind an event defined insise AuiFrame to that button?
I think that I do sthg wrong with my event handler, i.e. do not call the
event with a valid event handler ... ?
So I have my AuiFrame with a notebook inside (all the AUI demo)
# have a function in side AuiFrame to
#get a dialog etc and then trigger
#the make tab function
def OnNewCalculation(self, event):
self.MkTabPaneCustomer(self,calculationname)
# AUI demo about dialog
def OnAbout(self, event):
msg = "GUI approach "
dlg = wx.MessageDialog(self, msg, "ABOUT", wx.OK | wx.ICON_INFORMATION)
if wx.Platform != '__WXMAC__':
dlg.SetFont(wx.Font(8, wx.NORMAL, wx.NORMAL, wx.NORMAL, False))
dlg.ShowModal()
dlg.Destroy()
#I add a function that creates a new tab
def MkTabPaneCustomer(self, event, calculationname):
# create the new panel on which we put our sizers and ctrls
panel = wx.Panel(self)
# create a static box with label etc to be around it all
bordername = calculationname
panel.SetBackgroundColour('White')
box1 = wx.StaticBox(panel, -1, unicode(bordername))
box1.SetForegroundColour('Red')
font = box1.GetFont()
font.SetWeight(wx.BOLD)
box1.SetFont(font)
# and put a sizer inside it
box1_sizer = wx.StaticBoxSizer(box1, wx.VERTICAL)
# the controls
save_btn = wx.Button(panel, -1, u'Save')
clear_btn = wx.Button(panel, -1, u'Clear')
# add some functionality to the buttons
# the about box shows on load and when
#ok is pressed I get the assertion error
panel.Bind(wx.EVT_BUTTON, self.OnAbout(-1))
EXCEPTION:
AssertionError:
Datei "gui2-standaloneV6.py", Zeile 3695, in <module>
app.MainLoop()
Datei "C:\Python27\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py",
Zeile 8010, in MainLoop
wx.PyApp.MainLoop(self)
Datei "C:\Python27\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py",
Zeile 7306, in MainLoop
return _core_.PyApp_MainLoop(*args, **kwargs)
Datei
"C:\Python27\Lib\site-packages\wx-2.8-msw-unicode\wx\lib\agw\aui\auibar.py",
Zeile 3641, in OnLeftUp
self.ProcessEvent(e)
Datei "C:\Python27\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py",
Zeile 3863, in ProcessEvent
return _core_.EvtHandler_ProcessEvent(*args, **kwargs)
Datei "gui2-standaloneV6.py", Zeile 2918, in OnNewCalculation
self.MkTabPaneCustomer(self,calculationname)
Datei "gui2-standaloneV6.py", Zeile 2974, in MkTabPaneCustomer
panel.Bind(wx.EVT_BUTTON, self.OnAbout(-1))
Datei "C:\Python27\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py",
Zeile 3917, in Bind
assert callable(handler)
···
--
--------------------------------------------------
Tobias Weber
CEO
The ROG Corporation GmbH
Donaustaufer Str. 200
93059 Regensburg
Tel: +49 941 4610 57 55
Fax: +49 941 4610 57 56
www.roglink.com
Geschftsfhrer: Tobias Weber
Registergericht: Amtsgericht Regensburg - HRB 8954
UStID DE225905250 - Steuer-Nr.184/59359
--------------------------------------------------