Adding a toplevel widget
Prev | Chapter 6. wxGlade technical notes | Next

## Adding a toplevel widget

When the user clicks on a button of a toplevel widget (a Frame or a Dialog), the method “`add_toplevel_object`” of `wxGladeFrame` is called: this is responsible for the addition of the widget to the app. This happens in this way:

- the name of the class of the widget to add is obtained: this is done with the use of the “`common.refs`” dictionary, which maps the ids of the buttons of the palette to the class names of the widgets.

- with the name just obtained, the appropriate factory function for the widget to add is got from the “`common.widgets`” dictionary. This function must accept three parameters: a reference to the parent widget (`None` in this case), a reference to the sizer to which the widget will be added (again `None` for toplevel windows) and the zero-based position inside the sizer (once again, this is unused for toplevel windows)

- the call of the factory function actually builds the widgets and inserts it in the “`common.app_tree`” tree with a call to its method “`insert`”. The “`__init__`” method of the widget also builds all the Properties of the object and stores them in the 'self.properties' dict

Prev | Up | Next
Chapter 6. wxGlade technical notes | Home | Adding a toplevel sizer