我现在已经创建了与最初使用 tcl 的 gui builder 相同的用户界面。然而,它在我如何构建我的界面和小部件之间的间距方面变得有限。现在我已经创建了我的界面,我希望为特定的小部件创建一个过程块。例如,我想要退出按钮来退出程序。
为此,我创建了以下过程:
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
}