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.SetTitle(str(event.GetSize()))To get the current size of the window, we call the GetSize()method of the event object.Figure: sizeevent.pyPaintEventA paint event is generated when a window is redrawn. Thishappens when we resize a window or when we maximize it. Apaint event can be generated programatically as well. Forexample, when we call SetLabel() method to change awx.StaticText widget. Note that when we minimize a window, nopaint event is generated.#!/usr/bin/python# paintevent.pyimport wxclass PaintEvent(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title)self.count = 0self.Bind(wx.EVT_PAINT, self.OnPaint)self.Centre()self.Show(True)def OnPaint(self, event):self.count = self.count + 1print self.count12 de 14 27/04/2008 1:03

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

Saved successfully!

Ooh no, something went wrong!