Python Forum

Full Version: Bind error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
With Python2 I have this little script with an error in the line with "******" stars:
#!/usr/bin/python

import wx

def quit():
	print("Quit\n")

app = wx.App() 
w = wx.Frame(None) 
menuQuit = wx.Menu("Quit")
menuBar = wx.MenuBar()
menuBar.Append(menuQuit, "Operations")
w.SetMenuBar(menuBar)
w.Bind(wx.EVT_MENU, quit, menuQuit) #******This produces an error*****
w.Show(True) 

app.MainLoop()
This is the error message:
Error:
Traceback (most recent call last): File "./test.py", line 14, in <module> w.Bind(wx.EVT_MENU, quit, menuQuit) #******This produces an error***** File "/home/peter/.local/lib/python2.7/site-packages/wx/core.py", line 1403, in _EvtHandler_Bind assert source is None or hasattr(source, 'GetId')
What am I doing wrong?

Greetings
Peter
check out this link ecent handling wx The best information on wx python comes from a book with detailed explanations and code I liked wx python in action wx python in action