check_and_radio.tcl

来自「一个跨平台的TCL/TK可视开发环境类似VC. TCL/TK是一个跨平台的脚本」· TCL 代码 · 共 527 行 · 第 1/2 页

TCL
527
字号
    }
    set site_3_0 $base.fra81
    namespace eval ::widgets::$site_3_0.lab82 {
        array set save {-anchor 1 -background 1 -justify 1 -text 1}
    }
    namespace eval ::widgets::$site_3_0.rad83 {
        array set save {-anchor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::$site_3_0.rad84 {
        array set save {-anchor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::$site_3_0.rad85 {
        array set save {-anchor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::$site_3_0.rad86 {
        array set save {-anchor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::$site_3_0.rad87 {
        array set save {-anchor 1 -text 1 -value 1 -variable 1}
    }
    namespace eval ::widgets::$site_3_0.fra88 {
        array set save {-borderwidth 1}
    }
    set site_4_0 $site_3_0.fra88
    namespace eval ::widgets::$site_4_0.lab89 {
        array set save {-text 1}
    }
    namespace eval ::widgets::$site_4_0.lab90 {
        array set save {-background 1 -text 1 -textvariable 1}
    }
    namespace eval ::widgets_bindings {
        set tagslist _TopLevel
    }
    namespace eval ::vTcl::modules::main {
        set procs {
            init
            main
            showCheckedLabel
        }
        set compounds {
        }
    }
}
}

#################################
# USER DEFINED PROCEDURES
#
#############################################################################
## Procedure:  main

proc ::main {argc argv} {
showCheckedLabel
}
#############################################################################
## Procedure:  showCheckedLabel

proc ::showCheckedLabel {} {
set a [Toplevel1 setvar tomatoes]
set b [Toplevel1 setvar onions]
set c [Toplevel1 setvar mushrooms]
set d [Toplevel1 setvar artichokes]
set e [Toplevel1 setvar redbellpeppers]

Toplevel1 setvar checkedLabel "$a $b $c $d $e"
}

#############################################################################
## Initialization Procedure:  init

proc ::init {argc argv} {}

init $argc $argv

#################################
# VTCL GENERATED GUI PROCEDURES
#

proc vTclWindow. {base} {
    if {$base == ""} {
        set base .
    }
    ###################
    # CREATING WIDGETS
    ###################
    wm focusmodel $top passive
    wm geometry $top 200x200+110+125; update
    wm maxsize $top 1284 1006
    wm minsize $top 111 1
    wm overrideredirect $top 0
    wm resizable $top 1 1
    wm withdraw $top
    wm title $top "vtcl"
    bindtags $top "$top Vtcl all"
    vTcl:FireEvent $top <<Create>>
    wm protocol $top WM_DELETE_WINDOW "vTcl:FireEvent $top <<DeleteWindow>>"

    ###################
    # SETTING GEOMETRY
    ###################

    vTcl:FireEvent $base <<Ready>>
}

proc vTclWindow.top72 {base} {
    if {$base == ""} {
        set base .top72
    }
    if {[winfo exists $base]} {
        wm deiconify $base; return
    }
    set top $base
    ###################
    # CREATING WIDGETS
    ###################
    vTcl:toplevel $top -class Toplevel
    wm focusmodel $top passive
    wm geometry $top +252+136; update
    wm maxsize $top 1284 1006
    wm minsize $top 111 1
    wm overrideredirect $top 0
    wm resizable $top 1 1
    wm deiconify $top
    wm title $top "Check and Radio Buttons"
    vTcl:DefineAlias "$top" "Toplevel1" vTcl:Toplevel:WidgetProc "" 1
    bindtags $top "$top Toplevel all _TopLevel"
    vTcl:FireEvent $top <<Create>>
    wm protocol $top WM_DELETE_WINDOW "vTcl:FireEvent $top <<DeleteWindow>>"

    frame $top.fra74 \
        -borderwidth 2 
    vTcl:DefineAlias "$top.fra74" "Frame1" vTcl:WidgetProc "Toplevel1" 1
    set site_3_0 $top.fra74
    label $site_3_0.lab75 \
        -anchor w -background #e4dec4a5ecec \
        -text {A checkbutton shows an off / on state. It is associated with a variable.} 
    vTcl:DefineAlias "$site_3_0.lab75" "Label1" vTcl:WidgetProc "Toplevel1" 1
    checkbutton $site_3_0.che76 \
        -anchor w -command showCheckedLabel -text Tomatoes \
        -variable "$top\::tomatoes" 
    vTcl:DefineAlias "$site_3_0.che76" "Checkbutton1" vTcl:WidgetProc "Toplevel1" 1
    checkbutton $site_3_0.che77 \
        -anchor w -command showCheckedLabel -text Onions \
        -variable "$top\::onions" 
    vTcl:DefineAlias "$site_3_0.che77" "Checkbutton2" vTcl:WidgetProc "Toplevel1" 1
    checkbutton $site_3_0.che78 \
        -anchor w -command showCheckedLabel -text Mushrooms \
        -variable "$top\::mushrooms" 
    vTcl:DefineAlias "$site_3_0.che78" "Checkbutton3" vTcl:WidgetProc "Toplevel1" 1
    checkbutton $site_3_0.che79 \
        -anchor w -command showCheckedLabel -text Artichokes \
        -variable "$top\::artichokes" 
    vTcl:DefineAlias "$site_3_0.che79" "Checkbutton4" vTcl:WidgetProc "Toplevel1" 1
    checkbutton $site_3_0.che80 \
        -anchor w -command showCheckedLabel -text {Red bell peppers} \
        -variable "$top\::redbellpeppers" 
    vTcl:DefineAlias "$site_3_0.che80" "Checkbutton5" vTcl:WidgetProc "Toplevel1" 1
    label $site_3_0.lab91 \
        -anchor w -background #a708de3fecec -text {0 0 0 0 0} \
        -textvariable "$top\::checkedLabel" 
    vTcl:DefineAlias "$site_3_0.lab91" "Label5" vTcl:WidgetProc "Toplevel1" 1
    pack $site_3_0.lab75 \
        -in $site_3_0 -anchor center -expand 0 -fill x -side top 
    pack $site_3_0.che76 \
        -in $site_3_0 -anchor center -expand 0 -fill x -side top 
    pack $site_3_0.che77 \
        -in $site_3_0 -anchor center -expand 0 -fill x -side top 
    pack $site_3_0.che78 \
        -in $site_3_0 -anchor center -expand 0 -fill x -side top 
    pack $site_3_0.che79 \
        -in $site_3_0 -anchor center -expand 0 -fill x -side top 
    pack $site_3_0.che80 \
        -in $site_3_0 -anchor center -expand 0 -fill x -side top 
    pack $site_3_0.lab91 \
        -in $site_3_0 -anchor center -expand 0 -fill x -side top 
    frame $top.fra81 \
        -borderwidth 2 
    vTcl:DefineAlias "$top.fra81" "Frame2" vTcl:WidgetProc "Toplevel1" 1
    set site_3_0 $top.fra81
    label $site_3_0.lab82 \
        -anchor w -background #e4dec4a5ecec -justify left \
        -text {Radio buttons allow to choose one of several options.

Several radio buttons share the same variable.} 
    vTcl:DefineAlias "$site_3_0.lab82" "Label2" vTcl:WidgetProc "Toplevel1" 1
    radiobutton $site_3_0.rad83 \
        -anchor w -text Tee -value tee -variable "$top\::selectedButton" 
    vTcl:DefineAlias "$site_3_0.rad83" "Radiobutton1" vTcl:WidgetProc "Toplevel1" 1
    radiobutton $site_3_0.rad84 \
        -anchor w -text Coffee -value coffee \
        -variable "$top\::selectedButton" 
    vTcl:DefineAlias "$site_3_0.rad84" "Radiobutton2" vTcl:WidgetProc "Toplevel1" 1
    radiobutton $site_3_0.rad85 \
        -anchor w -text {Spring water} -value water \
        -variable "$top\::selectedButton" 
    vTcl:DefineAlias "$site_3_0.rad85" "Radiobutton3" vTcl:WidgetProc "Toplevel1" 1
    radiobutton $site_3_0.rad86 \
        -anchor w -text {Orange juice} -value orangejuice \
        -variable "$top\::selectedButton" 
    vTcl:DefineAlias "$site_3_0.rad86" "Radiobutton4" vTcl:WidgetProc "Toplevel1" 1
    radiobutton $site_3_0.rad87 \
        -anchor w -text {Iced tea} -value icedtea \
        -variable "$top\::selectedButton" 
    vTcl:DefineAlias "$site_3_0.rad87" "Radiobutton5" vTcl:WidgetProc "Toplevel1" 1
    frame $site_3_0.fra88 \
        -borderwidth 2 
    vTcl:DefineAlias "$site_3_0.fra88" "Frame3" vTcl:WidgetProc "Toplevel1" 1
    set site_4_0 $site_3_0.fra88
    label $site_4_0.lab89 \
        -text {You selected:} 
    vTcl:DefineAlias "$site_4_0.lab89" "Label3" vTcl:WidgetProc "Toplevel1" 1
    label $site_4_0.lab90 \
        -background #a708de3fecec -text {} \
        -textvariable "$top\::selectedButton" 
    vTcl:DefineAlias "$site_4_0.lab90" "Label4" vTcl:WidgetProc "Toplevel1" 1
    pack $site_4_0.lab89 \
        -in $site_4_0 -anchor center -expand 0 -fill none -side left 
    pack $site_4_0.lab90 \
        -in $site_4_0 -anchor center -expand 1 -fill x -side left 
    pack $site_3_0.lab82 \
        -in $site_3_0 -anchor center -expand 0 -fill x -side top 
    pack $site_3_0.rad83 \
        -in $site_3_0 -anchor center -expand 0 -fill x -side top 
    pack $site_3_0.rad84 \
        -in $site_3_0 -anchor center -expand 0 -fill x -side top 
    pack $site_3_0.rad85 \
        -in $site_3_0 -anchor center -expand 0 -fill x -side top 
    pack $site_3_0.rad86 \
        -in $site_3_0 -anchor center -expand 0 -fill x -side top 
    pack $site_3_0.rad87 \
        -in $site_3_0 -anchor center -expand 0 -fill x -side top 
    pack $site_3_0.fra88 \
        -in $site_3_0 -anchor center -expand 0 -fill x -side top 
    ###################
    # SETTING GEOMETRY
    ###################
    pack $top.fra74 \
        -in $top -anchor center -expand 0 -fill x -side top 
    pack $top.fra81 \
        -in $top -anchor center -expand 0 -fill x -side top 

    vTcl:FireEvent $base <<Ready>>
}

#############################################################################
## Binding tag:  _TopLevel

bind "_TopLevel" <<Create>> {
    if {![info exists _topcount]} {set _topcount 0}; incr _topcount
}
bind "_TopLevel" <<DeleteWindow>> {
    destroy %W; if {$_topcount == 0} {exit}
}
bind "_TopLevel" <Destroy> {
    if {[winfo toplevel %W] == "%W"} {incr _topcount -1}
}

Window show .
Window show .top72

main $argc $argv

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?