Working in an eventdriven environment

This chapter covers

■ Programming in an event-driven environment

■ Binding an event to a handler

■ Processing events using wxPython

■ Defining other application object event properties

■ Creating custom events

Event handling is the fundamental mechanism that makes wxPython programs work. A program that works primarily via event handling is called event driven. In this chapter, we will discuss what an event-driven application is, and how it differs from a traditional application. We'll provide an overview of the concepts and terminology involved in GUI programming, covering the interaction between the user, the toolkit, and the program logic. We'll also cover the lifecycle of a typical event-driven program.

An event is something that happens in your system which your application can respond to by triggering functionality. The event can be a low-level user action, such as a mouse move or key press, or a higher level user action given a specific meaning by wxPython because it takes place inside a wxPython widget, such as a button click or a menu selection. The event can also be created by the underlying operating system, such as a request to shut down. You can even create your own objects to generate your own events. A wxPython application works by associating a specific kind of event with a specific piece of code, which should be executed in response. The process by which events are mapped to code is called event handling.

This chapter will show what an event is, how you write code to respond to an event, and how the wxPython system knows to invoke your code when the event is triggered. We'll also show you how to add custom events to the wxPython library, which contains a listing of standard events for user and system activities.

Was this article helpful?

0 0

Post a comment