Class ::tycho::Subpanel


Inherits: ::tycho::TWidget - Source File - Contents: itk_options - public methods
This class defines a Subpanel widget that can be used within windows. It mimics opening and closing a drawer. The contents of the drawer can be any Tk window that is a child of the top-level window containing the subpanel.

The subpanel can be initially in an open or closed state. The -childwidget option specifies the widget to pack into the subpanel when the drawer is opened. Note that one childwidget cannot be packed into two different subpanels. The -text option specifies the text that is to be inserted into the label portion of the subpanel. The -state option specifies the state that the user would like the subpanel to have: either closed or open. One can query the current state of the subpanel by using [cget -state]. By default, the subpanel is initially closed.

Here is an example of how to use the Subpanel:

::tycho::Displayer .w
frame .w.options
checkbutton .w.options.a -text A
checkbutton .w.options.b -text B
pack .w.options.a
pack .w.options.b
::tycho::Subpanel .w.s -text "Options" -childwidget .w.options
pack .w.s -anchor w
wm deiconify .w

This example first creates a window with a status bar (and a close button), then creates a frame a populates it with checkbuttons. It then creates a Subpanel that uses the frame with checkbuttons as it's child widget. When the "open" button is pushed, that frame is packed. When it is pushed again, that frame is unpacked.

As an alternative to the -childwidget option, the -opencallback option specifies a command to execute when the subpanel is opened. This should return the name of a widget to be packed into the subpanel. Thus, the frame to display can be constructed on-the-fly. The -closecallback option specifies the command that is executed when a subpanel is closed.

For example,

proc nb {} {
    button .x.b -text push
    return .x.b
}
::tycho::Displayer .x
::tycho::Subpanel .x.s -text "Button"
.x.s configure -opencallback nb
.x.s configure -closecallback "destroy .x.b"
pack .x.s -anchor w
wm deiconify .x

If both the childwidget and the opencallback options are are used then the one that is specified last will be used. The deletion of the embedded widget is left to the creator.


Itk_options

-childwidget
Specify the name of a widget to be packed into the subpanel.
-closecallback
Specify the name of the procedure to execute when closing subpanel.
-opencallback
Specify the name of the procedure to execute when opening subpanel; The procedure should return the name of a widget to pack into the panel.
-state closed
Set state of subpanel to either open or closed.
-text
Specify the text to be inserted in the subpanel label.

Public constructs

Public Methods

close
Close the subpanel and hide the widgets inside. If a command exists that is to be executed upon closing then execute it before hiding the widgets.
open
Open the subpanel and displays the widgets If a command exists that is to be executed upon opening then execute it and pack the returned widget into the subpanel so it is displayed when subpanel is opened.

Index of classes



Author: Farhana Sheikh
Version: @(#)Subpanel.itcl 1.15 11/30/96
Copyright: (c) 1996 The Regents of the University of California.