The wxPython event API requires that it sends an event to the event handler. Thus when you do the Bind, you are going to be sending some type of event to the event handler.
Here are some links that may help you understand wxPython better:
Since you do not want to follow the toolkit's API, you can abuse Python and do something like this:
import wx
########################################################################
class Example(wx.Frame):
""""""
#----------------------------------------------------------------------
def __init__(self):
"""Constructor"""
wx.Frame.__init__(self, None, title="test")
panel = wx.Panel(self)
btn = wx.Button(panel, label="Close")
btn.Bind(wx.EVT_BUTTON, self.onClose)
#----------------------------------------------------------------------
def onClose(*args):
""""""
args[0].Destroy()
#----------------------------------------------------------------------
if __name__ == "__main__":
app = wx.App(False)
frame = Example()
frame.Show()
app.MainLoop()
This isn't recommended because you do not follow standard Python idioms by removing the reference to self in the onClose event handler. Of course, you are also removing the event from the method which is in violation of wxPython coding standards. But it does work!
event", do you mean you have to include it in the definition of your handler?onclose(your handler),eventis in arguments list, as it must be. So what exactly are you asking?Bindan event and a function, the event get sent to that function, so the function needs to expect it (even if you don't use it)