Tcl Tutorial

 

Table of Contents

Adding Callback Code

Callback code assigns programmatic actions to the components configured in the GUI. In this step, you will add code that displays a different message in the second label depending on which radio button is selected.

Each dialog project in Komodo contains two files. One file (with a "_ui" suffix in the file name, in this case "dlg_tcl_check_ui.tcl") is regenerated each time the GUI Builder is run. Therefore, user code should never be placed in this file. The other file (without the "_ui" suffix, in this case "dlg_tcl_check.tcl") is used to store the user code, which will be preserved regardless of future edits to the dialog.

Open the Program File

In the GUI Builder, select Commands|View Code. This will open the dlg_tcl_check.tcl file in the Komodo editor pane.

Top

Add Code to the Radio Buttons

In this section, you'll add code that will make a different message display in the label widget depending on which radio button is selected.

  1. On line 49, insert a line after the opening brace and enter the following code:
        variable BASE
        $BASE._label_2 configure -text "Free Bird"
    }
    
  2. On line 61, insert a line after the opening brace and enter the following code:
        variable BASE
        $BASE._label_2 configure -text "The Liberty Sessions"
    }
    
  3. On line 73, insert a line after the opening brace and enter the following code:
        variable BASE
        $BASE._label_2 configure -text "Radio Killed the Video Star"
    }
    

Note that the text is associated with the widget by specifying the widget name in the $BASE._label_2 statement, where "_label_2" is the name of the widget. To determine the name of a widget, double-click the widget in the GUI Builder and refer to the field at the top of the properties page.


Top Previous Next