13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Events in <strong>wxPython</strong>http://www.zetcode.com/wxpython/events/self.Bind(wx.EVT_BUTTON, self.OnClicked)def OnClicked(self, event):print 'event reached button class'event.Skip()class Propagate(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title, size=(250, 150))panel = MyPanel(self, -1)MyButton(panel, -1, 'Ok', (15, 15))self.Bind(wx.EVT_BUTTON, self.OnClicked)self.Centre()self.Show(True)def OnClicked(self, event):print 'event reached frame class'event.Skip()app = wx.App()Propagate(None, -1, 'Propagate')app.MainLoop()In our example, we have a button on a panel. <strong>The</strong> panel isplaced in a frame widget. We define a handler for all widgets.event reached button classevent reached panel classevent reached frame classWe get this, when we click on the button. <strong>The</strong> event travels fromthe button to panel and to frame.Try to omit some Skip() methods and see, what hapens.Window identifiersWindow identifiers are integers that uniquely determine thewindow identity in the event system. <strong>The</strong>re are three ways tocreate window id's.let the system automatically create an iduse standard identifierscreate your own id6 de 14 27/04/2008 1:03

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!