Glade Python Code Generator Signal Handling

Details on signal handling

For a signal like:

      <Signal>
        <name>add</name>
        <handler>on_combo1_add</handler>
        <object>window1</object>
      </Signal>
the following code will be generated in the handlers file:

      def on_combo1_add(widget, mainObj):
          pass

mainObj is a reference to the class produced in test.py. Each widget defined in test.glade is an attribute of mainObj. For example, given a glade definition:

    <widget>
      <class>GtkSpinButton</class>
      <name>spinbutton1</name>
      ...
    </widget>

    one can refer to this widget like this:

    def on_hscale1_value_changed(widget, mainObj):
	mainObj.spinbutton1.set_value(30)
Option Menus are a slight variation on this notion. For the following glade xml:
    
	    <widget>
	      <class>GtkOptionMenu</class>
	      <name>SetVariableMenu</name>
	      <border_width>2</border_width>
	      <child>
		<padding>0</padding>
		<expand>False</expand>
		<fill>False</fill>
	      </child>
	      <can_focus>True</can_focus>
	      <items>Display
Market
Sector
Maturity
Quality
</items>
	      <initial_choice>0</initial_choice>
	    </widget>

The following code is generated in the handlers file:
    
    def on_SetVariableMenu_menu_activate(widget, mainObj):
	pass
in which the mainObj is a list with two elements the first being a reference to the main class produced in the generated as the mainObj scalar in other signals, the second of which is the menu item number. Thus:

    def on_SetVariableMenu_menu_activate(widget, mainObj):
	mainObj[0].SetVariableMenuState = mainObj[1]
assigns the selected menu item to an attribute variable of the main GUI object.