wxpython parameter to EVT_MENU func
wurmy at earthlink.net
Wed Jan 23 12:07:06 EST 2002
Thomas Schultz wrote:
> how can I pass an object to a function called by EVT_MENU?
> I'm writing an application using wxgrid. I created a menu entry called
> SAVE. I call this function with:
> EVT_MENU(self, ID_SAVE, self.Save)
> def Save(self, event):
> In Save I have no acces to the grid, I tried:
> EVT_MENU(self, ID_SAVE, self.Save, grid)
> def Save(self, event, grid):
> but this doesn't work.
> How can I acces the grid in the function?
I usually use something like (pseudo-code!):
def __init__(self, parent, id):
EVT_MENU(self, ID_SAVE, self.Save)
self.grid = MyGrid(...)
def Save(self, event):
# now here you can access the MyGrid instance
# through self.grid.
I'm not exactly a wxPython expert, so maybe there are
better ways to do it. But this works for me.
# decode for email address ;-)
The Pythonic Quarter:: http://www.awaretek.com/nowak/
More information about the Python-list