Re: A question about event handlers with wxPython
Mike Driscoll [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Jan 15, 2:20 pm, Erik Lind [EMAIL PROTECTED] wrote: That all looks cool. I will experiment more. I'm a bit slow on this as only two weeks old so far. Thanks for the patience No problem. I'm pretty slow with some toolkits too...such as SQLAlchemy. Ugh. Mike BTW, The wxPython group that you mentionedis that http://wxforum.shadonet.com/? -- http://mail.python.org/mailman/listinfo/python-list
Re: A question about event handlers with wxPython
On Jan 16, 12:45 pm, Erik Lind [EMAIL PROTECTED] wrote: Mike Driscoll [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Jan 15, 2:20 pm, Erik Lind [EMAIL PROTECTED] wrote: That all looks cool. I will experiment more. I'm a bit slow on this as only two weeks old so far. Thanks for the patience No problem. I'm pretty slow with some toolkits too...such as SQLAlchemy. Ugh. Mike BTW, The wxPython group that you mentionedis thathttp://wxforum.shadonet.com/ ? I think those are C++ users using the pure C++ wx. I meant the following: http://wxpython.org/maillist.php Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: A question about event handlers with wxPython
def HandleSomething(self, event): generating_control = event.GetEventObject() print generating_control HTH, Thank you.That is what I was looking for, but as often seems the case, one thing exposes another. Is there any way to listen for events without specifically binding to a handler (it seems one cannot bind an event to two handlers?)? One could do so with globals, but I'm trying to avoid that. For example, press any button to stop def HandleSomething(self, event): . while generating_control: == something: run else stop -- http://mail.python.org/mailman/listinfo/python-list
Re: A question about event handlers with wxPython
On Jan 15, 9:04 am, Erik Lind [EMAIL PROTECTED] wrote: def HandleSomething(self, event): generating_control = event.GetEventObject() print generating_control HTH, Thank you.That is what I was looking for, but as often seems the case, one thing exposes another. Is there any way to listen for events without specifically binding to a handler (it seems one cannot bind an event to two handlers?)? One could do so with globals, but I'm trying to avoid that. For example, press any button to stop def HandleSomething(self, event): . while generating_control: == something: run else stop There are a number of ways to handle this. You could just bind the parent to the handler. Something like this: self.Bind(wx.EVT_BUTTON, self.onStop) This will bind all button presses to the onStop handler. You could also do something like this: self.Bind(wx.EVT_BUTTON, self.onBtnStop) def onBtnStop(self, event): #do something event.Skip() By calling the Skip() method, it will propagate the event and look for another handler, which in this case would be the onStop handler. On Windows, you will most likely need to make a wx.Panel be the parent of the rest of the widgets to have this effect. My complete test code is below. code import wx class Closer(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, wx.ID_ANY, title='Test Frame') panel = wx.Panel(self, -1) sizer = wx.BoxSizer(wx.VERTICAL) btn1 = wx.Button(panel, wx.ID_ANY, 'Button 1') btn2 = wx.Button(panel, wx.ID_ANY, 'Button 2') btn3 = wx.Button(panel, wx.ID_ANY, 'Button 3') sizer.Add(btn1) sizer.Add(btn2) sizer.Add(btn3) self.Bind(wx.EVT_BUTTON, self.onDone) self.Bind(wx.EVT_BUTTON, self.onStop, btn1) panel.SetSizer(sizer) def onStop(self, event): print 'Stop!' event.Skip() def onDone(self, event): print 'Done!' if __name__ == '__main__': app = wx.PySimpleApp() Closer().Show() app.MainLoop() /code FYI: There is an excellent wxPython group that you can join over on the wxPython.org website. Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: A question about event handlers with wxPython
On Jan 15, 9:04 am, Erik Lind [EMAIL PROTECTED] wrote: def HandleSomething(self, event): generating_control = event.GetEventObject() print generating_control HTH, Thank you.That is what I was looking for, but as often seems the case, one thing exposes another. Is there any way to listen for events without specifically binding to a handler (it seems one cannot bind an event to two handlers?)? One could do so with globals, but I'm trying to avoid that. For example, press any button to stop def HandleSomething(self, event): . while generating_control: == something: run else stop I forgot to provide a link to a fairly straight-forward explanation of event propagation on the wxPython wiki: http://wiki.wxpython.org/EventPropagation Hope that helps! Mike -- http://mail.python.org/mailman/listinfo/python-list
Re: A question about event handlers with wxPython
That all looks cool. I will experiment more. I'm a bit slow on this as only two weeks old so far. Thanks for the patience -- http://mail.python.org/mailman/listinfo/python-list
Re: A question about event handlers with wxPython
On Jan 15, 2:20 pm, Erik Lind [EMAIL PROTECTED] wrote: That all looks cool. I will experiment more. I'm a bit slow on this as only two weeks old so far. Thanks for the patience No problem. I'm pretty slow with some toolkits too...such as SQLAlchemy. Ugh. Mike -- http://mail.python.org/mailman/listinfo/python-list
A question about event handlers with wxPython
I'd appreciate any pointer on a simple way to tell within an event handler where the event came from. I want to have while condition in a handler to stop or change processing if an event occurs from some other button click. Trying to bind more than one event to the same handler still doesn't tell me where the event came from in a basic bind. Is there an argument I can put in the bind so as to identify the source of the event in the event argument? . -- http://mail.python.org/mailman/listinfo/python-list
Re: A question about event handlers with wxPython
Hello Eric, I'd appreciate any pointer on a simple way to tell within an event handler where the event came from. def HandleSomething(self, event): generating_control = event.GetEventObject() print generating_control HTH, -- Miki Tebeka [EMAIL PROTECTED] http://pythonwise.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list