Tcl/Tk Insight: Tk 基本组件

风行水上 @ 2009-07-04 09:33:02
标签:
    «目录»

    组件,在Tk中英文叫做 Widget。

    Button: 按钮

    Tk Demo Button

    http://www.tcl.tk/man/tcl8.4/TkCmd/button.htm

    Button(按钮)是常用的用来触发事件的控件。
    对于Button来说,关键属性包括

    • 显示什么? 字符串或者图片。
    • 要触发的命令是什么。

    其基本的使用相对比较简单,看起来像下面这个样子:

    #!/bin/wish
    
    proc cmd_btn_pushed {} {
      puts "The button is pushed"
    }
    
    button .btn -text "Push Me" -command {cmd_btn_pushed}
    button .btn_yellow -text "Yellow Button" -bg yellow
    
    pack .btn
    pack .btn_yellow
    

    标签:

      分享到:
      comments powered by Disqus

      28/32ms