📄 radiobox.itk
字号:
-variable [list [itcl::scope _modes($this)]] \ -anchor w \ -justify left \ -highlightthickness 0 \ -value $tag $args } { usual keep -state ignore -highlightthickness -highlightcolor rename -font -labelfont labelFont Font } lappend _buttons $tag grid $itk_component($tag) after idle [itcl::code $this _rearrange] return $tag}# ------------------------------------------------------------------# METHOD: insert index tag ?option value option value ...?## Insert the tagged radiobutton in the radiobox just before the # one given by index. Any additional options are passed on to the# radiobutton constructor. These include the typical radiobutton# options. The tag is returned.# ------------------------------------------------------------------itcl::body iwidgets::Radiobox::insert {index tag args} { set options {-value -variable} foreach option $options { if {[lsearch $args $option] != -1} { error "Error: specifying values for radiobutton component options\ \"-value\" and\n \"-variable\" is disallowed. The Radiobox must\ use these options when\n adding radiobuttons." } } itk_component add $tag { eval radiobutton $itk_component(childsite).rb[incr _unique] \ -variable [list [itcl::scope _modes($this)]] \ -highlightthickness 0 \ -anchor w \ -justify left \ -value $tag $args } { usual ignore -highlightthickness -highlightcolor rename -font -labelfont labelFont Font } set index [index $index] set before [lindex $_buttons $index] set _buttons [linsert $_buttons $index $tag] grid $itk_component($tag) after idle [itcl::code $this _rearrange] return $tag}# ------------------------------------------------------------------# METHOD: _rearrange## Rearrange the buttons in the childsite frame using the grid# geometry manager. This method was modified by Chad Smith on 3/9/00# to take into consideration the newly added -orient config option.# ------------------------------------------------------------------itcl::body iwidgets::Radiobox::_rearrange {} { if {[set count [llength $_buttons]] > 0} { if {$itk_option(-orient) == "vertical"} { set row 0 foreach tag $_buttons { grid configure $itk_component($tag) -column 0 -row $row -sticky nw grid rowconfigure $itk_component(childsite) $row -weight 0 incr row } grid rowconfigure $itk_component(childsite) [expr {$count-1}] \ -weight 1 } else { set col 0 foreach tag $_buttons { grid configure $itk_component($tag) -column $col -row 0 -sticky nw grid columnconfigure $itk_component(childsite) $col -weight 1 incr col } } }}# ------------------------------------------------------------------# METHOD: component ?name? ?arg arg arg...?## This method overrides the base class definition to provide some# error checking. The user is disallowed from modifying the values# of the -value and -variable options for individual radiobuttons.# Addition of this method prompted by SF ticket 227923.# ------------------------------------------------------------------itcl::body iwidgets::Radiobox::component {{name ""} args} { if {[lsearch $_buttons $name] != -1} { # See if the user's trying to use the configure method. Note that # because of globbing, as few characters as "co" are expanded to # "config". Similarly, "configu" will expand to "configure". if [regexp {^co+} [lindex $args 0]] { # The user's trying to modify a radiobutton. This is all fine and # dandy unless -value or -variable is being modified. set options {-value -variable} foreach option $options { set index [lsearch $args $option] if {$index != -1} { # If a value is actually specified, throw an error. if {[lindex $args [expr {$index + 1}]] != ""} { error "Error: specifying values for radiobutton component options\ \"-value\" and\n \"-variable\" is disallowed. The Radiobox\ uses these options internally." } } } } } eval chain $name $args}# ------------------------------------------------------------------# METHOD: delete index## Delete the specified radiobutton.# ------------------------------------------------------------------itcl::body iwidgets::Radiobox::delete {index} { set tag [gettag $index] set index [index $index] destroy $itk_component($tag) set _buttons [lreplace $_buttons $index $index] if {$_modes($this) == $tag} { set _modes($this) {} } after idle [itcl::code $this _rearrange] return}# ------------------------------------------------------------------# METHOD: select index## Select the specified radiobutton.# ------------------------------------------------------------------itcl::body iwidgets::Radiobox::select {index} { set tag [gettag $index] $itk_component($tag) invoke}# ------------------------------------------------------------------# METHOD: get## Return the tag of the currently selected radiobutton.# ------------------------------------------------------------------itcl::body iwidgets::Radiobox::get {} { return $_modes($this)}# ------------------------------------------------------------------# METHOD: deselect index## Deselect the specified radiobutton.# ------------------------------------------------------------------itcl::body iwidgets::Radiobox::deselect {index} { set tag [gettag $index] $itk_component($tag) deselect}# ------------------------------------------------------------------# METHOD: flash index## Flash the specified radiobutton.# ------------------------------------------------------------------itcl::body iwidgets::Radiobox::flash {index} { set tag [gettag $index] $itk_component($tag) flash }# ------------------------------------------------------------------# METHOD: buttonconfigure index ?option? ?value option value ...?## Configure a specified radiobutton. This method allows configuration # of radiobuttons from the Radiobox level. The options may have any # of the values accepted by the add method.# ------------------------------------------------------------------itcl::body iwidgets::Radiobox::buttonconfigure {index args} { set tag [gettag $index] eval $itk_component($tag) configure $args}# ------------------------------------------------------------------# CALLBACK METHOD: _command name1 name2 opt ## Tied to the trace on _modes($this). Whenever our -variable for our# radiobuttons change, this method is invoked. It in turn calls# the user specified tcl script given by -command.# ------------------------------------------------------------------itcl::body iwidgets::Radiobox::_command { name1 name2 opt } { uplevel #0 $itk_option(-command)}# ------------------------------------------------------------------# METHOD: gettag index## Return the tag of the checkbutton associated with a specified# numeric index# ------------------------------------------------------------------itcl::body iwidgets::Radiobox::gettag {index} { return [lindex $_buttons [index $index]]}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -