[wxPython-users] A puzzling example -- events
Christopher Barker
Chris.Barker at noaa.gov
Mon Apr 23 10:16:38 PDT 2007
7stud wrote:
> The following example was offered up as a demonstration of how
> specifying the source of an event in Bind()
Where was that example?
> The following is the kind of example
> I would show someone who wanted to learn what the "source"
> parameter in Bind() does:
That is a better example -- maybe you could put in the Wiki.
note, however:
button1 = wx.Button(panel, -1, "Button1", pos=(130,15),
size=(100,40) )
button2 = wx.Button(panel, -1, "Button2", pos=(130,50),
size=(100,40) )
self.Bind(wx.EVT_BUTTON, self.OnButton1Click, button1)
self.Bind(wx.EVT_BUTTON, self.OnButton2Click, button2)
I'd be far more likely to write this as:
button1.Bind(wx.EVT_BUTTON, self.OnButton1Click)
button2.Bind(wx.EVT_BUTTON, self.OnButton2Click)
See the wxPython style guide in the Wiki.
I like this better for two reasons:
1) I think it's more obvious what's intended
2) is works with both command and regular events.
The only place you cant do this is with menu items, because they aren't
"true" wx.Windows -- too bad.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the wxpython-users
mailing list