TCL:在同一框架区

时间:2016-02-10 11:04:11

标签: tcl tk

我正在开发一个基于Tcl的ui。我的主窗口上有几个按钮。对于每个按钮动作,我想在同一个tcl框架中显示一个小部件,并且当单击按钮2时也应该用另一个小部件覆盖它。 任何示例链接将不胜感激。 这是我完整小部件的代码。

####################################################################################
package require Tk

set model_type None
wm title . "Impetus interactive: MXL Library Validation Tool V1.0"

wm iconname . "LibValidation"

wm geometry . +150+250


##+######################################################
## Set the COLOR SCHEME for the WINDOW ---
## and background colors for its WIDGETS.
##+######################################################

# set Rpal255 200
# set Gpal255 200
# set Bpal255 255
##set Rpal255 210
##set Gpal255 210
##set Bpal255 210

##set hexPALcolor [format "#%02X%02X%02X" $Rpal255 $Gpal255 $Bpal255]

#tk_setPalette "$hexPALcolor"

## Set color background for some WIDGETS.

##set scaleBKGD "#f0f0f0"
# set radbuttBKGD "#c0c0c0"
# set chkbuttBKGD "#c0c0c0"
# set listboxBKGD "#f0f0f0"
set entryBKGD   "#f0f0f0"
set textBKGD    "#f0f0f0"

##Set (temporary) FONT-NAMES.
##
## We use a VARIABLE-WIDTH FONT for LABEL and BUTTON widgets.
##
## We use a FIXED-WIDTH FONT for TEXT widgets (to preserve
## alignment of columns in text), LISTBOXES (to preserve
## alignment of characters in lists), and ENTRY fields
## (to make it easy to position the text cursor at narrow
## characters like i, j, l, and the number 1).
##+##########################################################

font create fontTEMP_varwidth \
   -family {comic sans ms} \
   -size -14 \
   -weight bold \
   -slant roman

font create fontTEMP_SMALL_varwidth \
   -family {comic sans ms} \
   -size -12 \
   -weight bold \
   -slant roman

font create fontTEMP_fixedwidth  \
   -family {liberation mono} \
   -size -14 \
   -weight bold \
   -slant roman

font create fontTEMP_SMALL_fixedwidth  \
   -family {liberation mono} \
   -size -12 \
   -weight bold \
   -slant roman


##+###########################################################
## Set GEOMETRY PARAMETERS for the various widget definitions.
## (e.g. width and height of canvas, and padding for Buttons)
##+###########################################################

## CANVAS geom parms:

##set initCan1WidthPx  200
#set initCan1HeightPx 150

##set initCan2WidthPx  255
##set initCan2HeightPx 255


# set BDwidthPx_canvas 2
##set BDwidthPx_canvas 0


## LABEL geom parameters:

set PADXpx_label 0
set PADXpx2_label 1
set PADYpx_label 0
set PADYpx2_label 1
set BDwidthPx_label 2


## BUTTON geom parameters:

set PADXpx_button 0
set PADYpx_button 0
set BDwidthPx_button 2
set PADXpx2_button 2
set PADXpx3_button 3
set PADYpx2_button 2
set PADYpx3_button 3
set BDwidthPx2_button 2
set PADXpx4_button 1
set PADXpx5_button 1
set PADYpx4_button 1
set PADYpx5_button 1


## SCALE geom parameters:

##set BDwidthPx_scale 2
#set initScaleLengthPx 300
##set scaleWidthPx 10

## ENTRY geom parameters:

set BDwidthPx_entry 2
set BDwidthPx_entry2 2
set initImgfileEntryWidthChars 25


##+###################################################################
## DEFINE *ALL* THE FRAMES:
## 
##   Top-level :  '.fRbuttons'   '.fRfile'   'fRfile2'  '.fRimages'
##
##   Sub-frames: '.fRimages.fRcanvas1'    '.fRimages.fRcanvas2'
##+###################################################################

## FOR TESTING: (to check frame sizes as window is resized)
 set BDwidth_frame 2
 set RELIEF_frame flat

set BDwidth_frame 0
set RELIEF_frame flat

frame .top -borderwidth 10 

pack .top -side top -fill both


frame .fRbuttons  -relief $RELIEF_frame  -borderwidth $BDwidth_frame

frame .fRfile     -relief $RELIEF_frame  -borderwidth $BDwidth_frame



################################################################################
##image create photo img -file "maxL.gif"
canvas .top.myCanvas -background white  -width 100 -height 50
pack .top.myCanvas -side top -anchor nw  -fill none -padx 2 -pady 2
set myImage [image create photo]
$myImage read "/home/dshaikh/Library_Val/FF_0.99v_125/maxL.gif"
.top.myCanvas create image 55 30 -image $myImage

#####################################################################################

menu .mbar
. configure -menu .mbar
menu .mbar.fm -tearoff 0
.mbar add cascade -menu .mbar.fm -label FILE \
    -underline 0
menu .mbar.hm -tearoff 0 
.mbar add command -label HELP \
    -underline 0 -command {popup_msgVarWithScroll .topHelp "$HELPtext"}



menu .mbar.fm.sb
.mbar.fm.sb add command -label List
.mbar.fm.sb add command -label Bookmarks
.mbar.fm.sb add command -label Mail

labelframe .top.ff  -font fontTEMP_varwidth -text "Input and Run options" -padx 2 -pady 2 -bd 2 
button .f -text "Inputs"  -relief raised -command {take_inputs} 
#pack .f -side left -ipadx 2 -ipady 2 -padx 3 -pady 3
button .v -text "Unit Level" -relief raised -command {Run_Unit_level}
##pack .v -side left -ipadx 2 -ipady 2 -padx 3 -pady 3
button .u -text "Interaction Level" -relief raised -command {Run_Interaction_level}
#pack .u -side left -ipadx 2 -ipady 2 -padx 3 -pady 3
button .l -text "Flow Level" -relief raised -command {Run_Flow_Level} 
button .e -text "LogFile" -relief raised -command {show_logfile}
pack .f .v .u .l .e -in .top.ff -fill both  -padx 2 -pady 2 
pack .top.ff  -side left  -anchor nw -ipadx 4 -ipady 4 -expand y 


#############################################################
########### Creating a logfile area ###################



frame .p

set sum [text .p.log -width 80 -height 10  -borderwidth 2 -background LightYellow -relief raised -setgrid true -borderwidth 6 -relief raised -setgrid true -yscrollcommand {.p.scroll set}]
scrollbar .p.scroll -command {.p.log yview}
pack .p.scroll -side right -fill y
pack .p.log -side right -fill both -expand true
pack .p -side right -fill both -expand true

由于 丹

0 个答案:

没有答案