The Widget namespace handle data associated to all BWidget and provide commands
to easily define BWidget.
For commands can be used to define a BWidget:
tkinclude, bwinclude, declare, addmap and syncoptions.
Here is the definition of ComboBox widget:
namespace eval ComboBox { # We're using ArrowButton, Entry and LabelFrame ArrowButton::use Entry::use LabelFrame::use # Include resources of LabelFrame Widget::bwinclude ComboBox LabelFrame .labf \ rename {-text -label} \ remove {-focus} \ prefix {label -justify -width -anchor -height -font} \ initialize {-relief sunken -borderwidth 2} # Include resources of Entry Widget::bwinclude ComboBox Entry .e \ remove {-relief -bd -borderwidth -bg -fg} \ rename {-foreground -entryfg -background -entrybg} # Declare new resources Widget::declare ComboBox { {-height TkResource 0 0 listbox} {-values String "" 0} {-modifycmd String "" 0} {-postcommand String "" 0} } # Map resources to subwidget Widget::addmap ComboBox "" :cmd {-background {}} Widget::addmap ComboBox ArrowButton .a \ {-foreground {} -background {} -disabledforeground {} -state {}} # Synchronize subwidget options Widget::syncoptions ComboBox Entry .e {-text {}} Widget::syncoptions ComboBox LabelFrame .labf {-label -text -underline {}} proc use {} {} } |
If rename is false, the path will not be renamed, but the proc will still be created. This is useful when inheriting another BWidget who will already have renamed the widget.
The command returns the widget path. This command is usually the last command executed in the ::create command for the widget.
This command is used to define a new BWidget class. It is usually the first command executed in a new widget definition.
Each class defined after the filename is a class that this widget depends on. The ::use command will be called for each of these classes after the new widget has been defined.
This command does several things to setup the new class. First, it creates an alias in the global namespace for the name of the class that points to the class's ::create subcommand. Second, it defines a ::use subcommand for the class which other classes can use to load this class on the fly. Lastly, it creates a default binding to the <Destroy> event for the class that calls Widget::destroy on the path. This is the default setup for almost all widgets in the BWidget package.
Make the variable varName relational to path accessible in the current procedure. The variable will be created in the widget namespace for path and can be used for storing widget-specific information. When path is destroyed, any variable accessed in this manner will be destroyed with it.
If myVarName is specified, the variable will be accessible in the current procedure as that name.