Panels muß man wohl generell haben, wenn man Buttons hat...
Aber, zurück zu meinem Umstrickversuchen... Leider klappt es nicht...
mainFrame.py
Code: Alles auswählen
class mainFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: mainFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.mainPanel = wx.Panel(self, -1)
# Menu Bar
self.frame_1_menubar = wx.MenuBar()
self.SetMenuBar(self.frame_1_menubar)
self.menue_about = wx.Menu()
self.frame_1_menubar.Append(self.menue_about, "about")
# Menu Bar end
self.frame_1_statusbar = self.CreateStatusBar(1, 0)
self.label_2 = wx.StaticText(self.mainPanel, -1, "Status:")
self.info_textfeld = wx.TextCtrl(self.mainPanel, -1, "", style=wx.TE_MULTILINE|wx.TE_LINEWRAP)
self.button_readCD = wx.Button(self.mainPanel, -1, "CD-ROM einlesen")
HauptProgramm:
Code: Alles auswählen
class MyFrame(wx.Frame):
def __init__(self):
self.Frame = mainFrame.mainFrame(None, -1)
self.Frame.Show()
self.Frame.SetStatusText( "TEST" )
wx.EVT_MENU(self, self.Frame.menue_about.GetId(), self.test)
wx.EVT_BUTTON(self, self.Frame.button_readCD.GetId(), self.test)
def test(self, event):
print "JAU!"
sys.exit()
app = wx.PySimpleApp()
MyFrame()
app.MainLoop()
Bei wx.EVT_MENU bekomme ich:
Code: Alles auswählen
Traceback (most recent call last):
File "test.py", line 87, in ?
MyFrame()
File "test.py", line 78, in __init__
wx.EVT_MENU(self, self.Frame.menue_about.GetId(), self.test)
AttributeError: 'Menu' object has no attribute 'GetId'
Bei wx.EVT_BUTTON das:
Code: Alles auswählen
Traceback (most recent call last):
File "test.py", line 87, in ?
MyFrame()
File "test.py", line 79, in __init__
wx.EVT_BUTTON(self, self.Frame.button_readCD.GetId(), self.test)
File "D:\Python\Python\Lib\site-packages\wx-2.5.3-msw-ansi\wx\_core.py", line 2808, in __call__
self.Bind(target, id1, id2, func)
File "D:\Python\Python\Lib\site-packages\wx-2.5.3-msw-ansi\wx\_core.py", line 2774, in Bind
target.Connect(id1, id2, et, function)
File "D:\Python\Python\Lib\site-packages\wx-2.5.3-msw-ansi\wx\_core.py", line 2696, in Connect
return _core_.EvtHandler_Connect(*args, **kwargs)
TypeError: Expected a pointer
Ich denke die schwirigkeit liegt darin, das ich die aus wxGlade ausgespucken *.py Dateien unberührt belassen will... Darauf dann zu referenzieren ist schon ziemlich kompliziert für mich
