What do I need to know about the required objects

Let's start with a description of the two foundation objects. The application object manages the main event loop, which is the heartbeat of your wxPython program. The event loop will be covered in detail in chapter 3. For now, it is enough to say that it is the application object's job to start the main event loop. In addition, the application object has the final chance to respond to any events which are otherwise ignored by your application. Without the application object, your wxPython application cannot run.

The top-level window object generally manages the most important data and controls and presents them to the user. For example, in a word-processing program, the main window is the display of the document, and will likely manage at least some of the data for the document (depending, of course, on the exact architecture of your application). Similarly, the main window of your web browser both displays the page you are looking at and manages that page as a data object.

Figure 2.1 gives a basic schematic of the relationship between the two foundation objects and the rest of your application.

As this diagram shows, the application object "owns" both the top-level window and the main event loop. The top-level window manages the components in that window, and any other data objects you assign to it. That window and its components trigger events based on user actions, and receive event notifications to make changes in the display. In the next sections, we'll discuss the application and top-level window objects in more detail.

Event ^- Window Components

Loop

Figure 2.1 A schematic of the basic wxPython application structure, showing the relationship between the application object, the top-level window, and the main event loop

Event ^- Window Components

Loop

Figure 2.1 A schematic of the basic wxPython application structure, showing the relationship between the application object, the top-level window, and the main event loop

Was this article helpful?

0 0

Post a comment