first previous next last contents

The Dialogue Creation

Firstly, we need to create the dialogue. This is done using both standard Tk commands and extra widgets defined in the tk_utils package. For the composition package the dialogue procedure is as follows.

proc Composition {io} {
    global composition_defs

    # Create a dialogue window
    set t [keylget composition_defs COMPOSITION.WIN]
    if [winfo exists $t] {
        raise $t
    toplevel $t

    # Add the standard contig selector dialogues
    contig_id $ -io $io
    lorf_in $t.infile [keylget composition_defs COMPOSITION.INFILE] \
        "{contig_id_configure $ -state disabled}
         {contig_id_configure $ -state disabled}
         {contig_id_configure $ -state disabled}
         {contig_id_configure $ -state normal}
        " -bd 2 -relief groove

    # Add the ok/cancel/help buttons
    okcancelhelp $t.but \
        -ok_command "Composition2 $io $t $ $t.infile" \
        -cancel_command "destroy $t" \
        -help_command "show_help %composition Composition"

    pack $t.infile $ $t.but -side top -fill both

Firstly we define the procedure name. In this case we'll call it Composition. It takes a single argument which is the IO handle of an opened Gap4 database.

Next we need to create a new window. We've stored the Tk pathname of this window in the COMPOSITION.WIN keyed list value in the defaults for this package. As our package is called composition the defaults are composition_defs. We define them as global and use keylget to fetch the window pathname. It is wise to check that the dialogue window doesn't already exist before attempting to create a new one. This could happen if the user selects the option from the main menu twice without closing down the first dialogue window.

Then the real dialogue components are added. In this case these consist of contig_id, lorf_in and okcancelhelp widgets. These are explained (FIXME: will be...) in the tk_utils and gap4 chapters. Note that the okcancelhelp command requires three Tcl scripts to execute when each of the Ok, Cancel and Help buttons are pressed.

For the Ok button we call the Composition2 procedure with the widget pathnames containing the users selections. The Cancel button is easy as we simply need to destroy the dialogue window. The Help button will call the show_help command to display the appropriate documentation. More on this later.

first previous next last contents
This page is maintained by staden-package. Last generated on 1 March 2001.