Chapter 6. wxGlade technical notes

Caution

Last update: 2003-06-26, but only the section called “For contributors”.

The rest has not been updated since 2002-07-22, and it's likely be very outdated in some parts.

This is an informal overview of wxGlade internals, made through a sample session of use. Each action of the hypotetical user will be described from the point of view of the application, to (hopefully) understand what's happening behind the scenes.

These notes are absolutely incomplete and in some cases they might be outdated or not completely correct: the best reference is always the source code.

Startup

The program starts from the function main in the module main: this creates an instance of wxGlade (a subclass of wxApp), which in turn creates a wxGladeFrame: this is the main window of the app, i.e. the one with the palette of buttons. The initialization of wxGladeFrame consists of three steps:

  • Creation of the three frames of the app, the palette itself, the tree and the property window

  • Loading of the code generator modules. The codegen/ subdir is scanned to find the available code generators: when a python module is found, the app tries to load it and to access its 'writer' attribute: if this is succesfully accomplished, such 'writer' object is considered a valid code generator, and is inserted into the 'common.code_writers' dict (the key used is the 'language' attribute of the writer itself)

  • Loading of the widget and sizer modules. To load the widgets, the file widgets/widgets.txt is read, and the app tries to import every widget module listed on such file. For every module succesfully imported, the initialize function is then called: this function sets up the builder and code generator functions for a particular widget (explained later), and returns a wxBitmapButton instance to be added to the main palette. The loading of the sizers is more or less the same, except that all the sizers are in the same module, edit_sizers, and the initialization function (called init_gui) returns a list of wxBitmapButton objects