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/Python IDEFaster, Home Easier ContentsPython Development Editor,Debugger, Browser, and moreScrumFormation, Services, Conseil TDD, C++,Java J2EE, Ruby, PythonEvents in <strong>wxPython</strong>Events are integral part of every GUI application. All GUIapplications are event-driven. An application reacts to differentevent types which are generated during it's life. Events aregenerated mainly by the user of an application. But they can begenerated by other means as well. e.g. internet connection,window manager, timer. So when we call MainLoop() method,our application waits for events to be generated. <strong>The</strong> MainLoop()method ends when we exit the application.DefinitionsEvent is a piece of application-level information from theunderlying framework, typically the GUI toolkit. Event loop is aprogramming construct that waits for and dispatches events ormessages in a program. <strong>The</strong> event loop repeatedly looks forevents to process them. A dispatcher is a process which mapsevents to event handlers. Event handlers are methods thatreact to events.Event object is an object associated with the event. It isusually a window. Event type is a unique event, that has beengenerated. Event binder is an object, that binds an event typewith an event handler.A simple event exampleIn the following section we will describe a simple event. We willtalk about a move event.A move event is generated, when we move a window to a newposition. <strong>The</strong> event type is wx.MoveEvent. <strong>The</strong> event binder forthis event is wx.EVT_MOVE#!/usr/bin/python# moveevent.py1 de 14 27/04/2008 1:03

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

Saved successfully!

Ooh no, something went wrong!