【问题标题】:tcl entry with some default text带有一些默认文本的 tcl 条目
【发布时间】:2017-10-23 10:50:01
【问题描述】:

我想要一个在框中显示一些默认文本的条目小部件。 -状态禁用。当我单击编辑按钮时,它将启用并且我可以更改文本。我可以管理编辑按钮部分,只需要有关条目小部件的帮助。

我已尝试使用此代码:

entry .e1 -text "abcd" -state disable
pack .e1 -in .WorkArea -side left

【问题讨论】:

    标签: tcl tk


    【解决方案1】:
    frame .workArea
    pack .workArea
    

    请注意,-text 选项是-textvariable 的缩写,即包含输入到条目小部件中的文本的全局变量的名称。将该变量设置为一个值会为条目提供一些文本。

    entry .e1 -textvariable abcd -state disabled
    set abcd wxyz
    pack .e1 -in .workArea -side left
    

    您现在需要一个按钮,将入口小部件配置为在按下时正常(启用):

    button .b1 -text Enable -command {.e1 configure -state normal}
    pack .b1 -in .workArea -side left
    

    文档: button (widget), entry, frame (widget), pack, set

    【讨论】:

      猜你喜欢
      • 2012-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多