13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Events in <strong>wxPython</strong>http://www.zetcode.com/wxpython/events/wx.ScrollEvent.#!/usr/bin/python# myscrollwinevent.pyimport wxclass ScrollWinEvent(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title)panel = wx.Panel(self, -1)self.st = wx.StaticText(panel, -1, '0', (30,0))panel.Bind(wx.EVT_SCROLLWIN, self.OnScroll)panel.SetScrollbar(wx.VERTICAL, 0, 6, 50);self.Centre()self.Show(True)def OnScroll(self, evt):y = evt.GetPosition()self.st.SetLabel(str(y))app = wx.App()ScrollWinEvent(None, -1, 'scrollwinevent.py')app.MainLoop()SizeEventA wx.SizeEvent is generated, when our window is resized. In ourexample, we show the size of the window in the titlebar.#!/usr/bin/python# sizeevent.pyimport wxclass SizeEvent(wx.Frame):def __init__(self, parent, id, title):wx.Frame.__init__(self, parent, id, title)self.Bind(wx.EVT_SIZE, self.OnSize)self.Centre()self.Show(True)def OnSize(self, event):self.SetTitle(str(event.GetSize()))app = wx.App()SizeEvent(None, 1, 'sizeevent.py')app.MainLoop()11 de 14 27/04/2008 1:03

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

Saved successfully!

Ooh no, something went wrong!