0
我现在已经创建了相同的用户界面,最初使用GUI构建器为tcl。然而,就我如何构造我的界面和小部件之间的间距而言,它受到了限制。现在,我已经创建了我的界面,我正在为特定的窗口小部件创建一个过程块。例如,我想退出按钮退出程序。链接过程到按钮
要做到这一点,我创建了以下过程:
proc btnQuit args {
exit
}
这不会导致语法或运行时错误然而,当按下按钮时,程序不会退出。这是最简单的情况,因为还有其他更复杂的命令,因此-command标志不适用于所有情况。
想法?
下面是我的整个代码。这只是提出了用户界面。
#Includes the necessary packages
package require BWidget
package require Tk
namespace eval Main_Menu {}
#DO NOT MODIFY!! Graphical User Interface Code DO NOT MODIFY!!
#Limit the size of window
wm maxsize . 475 180 ;#x-500, y-210
wm minsize . 475 180 ;#x-500, y-210
#[Device name] Test Frame w/ associated check boxes
labelframe .lblfrmSelection -text "Testable Devices" -padx 1 -relief groove -height 175 -width 200
button .btnDualUTA -text "Dual UTA" -padx 5 -anchor "center" -justify "center" -padx 3
button .btnTProbe -text "T-Probe" -padx 5 -anchor "center" -justify "center" -padx 7
button .btnOctal -text "Octal" -padx 5 -anchor "center" -justify "center" -padx 14
button .btnUniversal -text "Universal" -padx 5 -anchor "center" -justify "center"
button .btnQuit -text "Exit" -padx 5 -anchor "center" -justify "center" -padx 18
#Setup second frame with image label
labelframe .lblfrmHWSetup -text "Hardware Setup" -padx 1 -relief groove -height 200 -width 175
image create photo glcomm.gif
label .lblSetup -text "Image goes here"
#*************** Render User Environment ******************
#Create Device Test Interface with check boxes in frame.
place .lblfrmSelection -anchor nw -x 5 -y 1 -width 165 -height 175
place .btnDualUTA -in .lblfrmSelection -x 40 -y 15 -anchor "w"
place .btnTProbe -in .lblfrmSelection -x 40 -y 46 -anchor "w"
place .btnOctal -in .lblfrmSelection -x 40 -y 76 -anchor "w"
place .btnUniversal -in .lblfrmSelection -x 40 -y 106 -anchor "w"
place .btnQuit -in .lblfrmSelection -x 40 -y 136 -anchor "w"
#Create label frame "Hardware Setup"
place .lblfrmHWSetup -anchor nw -x 170 -y 1 -height 175 -width 300
place .lblSetup -in .lblfrmHWSetup -x 171 -y 2
# MODIFY BELOW THIS LINE!! MODIFY BELOW THIS LINE!!
proc btnQuit args {
exit
}
我已经提供了代码,这是我的用户界面。你在全球命名空间中意味着什么?我实际上并没有理解命名空间是什么,即使我已经在我的代码中使用< - 我从GUI构建器创建的代码中复制它。 – ButtahNBred
看起来像所有你需要的是'.btnQuit configure -command btnQuit'后你的btnQuit proc –
它似乎没有做任何事情。 proc btnQuit {.btnQuit configure -command btnQuit} 该程序不会退出。我也尝试从最后删除“btnQuit”。 – ButtahNBred