[wxPython-users] How to pass a parameter with an event binding?

Alec Bennett whatyoulookin at yahoo.com
Sun Dec 9 14:52:35 PST 2007


Yes, but the whole point is to have more than one
button triggering that function but with different
parameters. Using that method, only the last variable
is registered.

For example:

# button1
self.button1 = wx.Button(panel, -1, label="Start")
self.parameterVal = "something"  
self.button1.Bind(wx.EVT_BUTTON, self.OnStart)

#button2
self.button2 = wx.Button(panel, -1, label="Start")
self.parameterVal = "something else"  
self.button2.Bind(wx.EVT_BUTTON, self.OnStart)

def OnStart(self, event):
  ....print self.parameterVal

Using the above method, when button 1 is clicked it'll
still print "something else" when button 1 is clicked.








--- David Woods <dwoods at wcer.wisc.edu> wrote:

> You could use an object property to hold the value
> you want passed,
> something like this:
> 
>  self.button1 = wx.Button(panel, -1, label="Start")
>  self.parameterVal = "something"
>  
>  self.button1.Bind(wx.EVT_BUTTON, self.OnStart)
> 
>  def OnStart(self, event):
>  ....print self.parameterVal
> 
> David
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail:
> wxPython-users-help at lists.wxwidgets.org
> 
> 



      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 





More information about the wxpython-users mailing list