#!/usr/bin/wish -f ## ## SCRIPT: make_chest_proto_buttonsInFrames.tk ## ## in $FEDIR/tkGUIs/tkGUIs_DEMOS/feTkDEMOs/NEW_2012jul-aug ## ## where FEDIR = $HOME/apps/fehandytools_2011oct23 ##+############################################################################ ## DESCRIPTION: This Tk script ## ## MAKES TOOLCHEST DRAWERS WITH: 'button' widgets ## PROVIDES DRAWER ACTIONS WITH: the '-command' parm of 'button' ## PROVIDES TOOLCHEST/DRAWER DECORATION WITH: 'tk_setPalette' command, with ## an optional 'bullet' image on the left of each button/drawer. ##+########################################################################### ## REFERENCES: ## This script is based on (is simplified from) ## the original 'make_chest.tk' script of the feAppMenus subsystem ## of the Freedom Environment software. See freedomenv.com. ## ## See similar toolchest-making test scripts in this series: ## ## 1) 'make_chest_proto_gradientLinesInCanvases.tk' --- ## ## MAKES TOOLCHEST DRAWERS WITH: 'canvas' widgets ## PROVIDES DRAWER ACTIONS WITH: button-release bindings on the canvas widgets ## PROVIDES TOOLCHEST/DRAWER DECORATION WITH: 'create line' commands on ## the canvas widgets --- to provide COLOR GRADIENT BACKGROUNDS for ## the 'drawers' ; uses a 'DrawGradient' proc based on ## a Tcl-Tk script by Damon Courtney and published at ## http://wiki.tcl.tk/6100 - Drawing color gradients. ## ## 2) 'make_chest_proto_imageCreateInCanvases_txt-can-arrays.tk' --- ## ## MAKES TOOLCHEST DRAWERS WITH: 'canvas' widgets ## PROVIDES DRAWER ACTIONS WITH: button1-release bindings on the canvas widgets ## PROVIDES TOOLCHEST/DRAWER DECORATION WITH: 'image create' on the ## canvas widgets, using a rectangular GIF image file that is used ## to make an image var with 'image create photo'. That image var ## is used in the 'image create' statements. ## ## The 'txt-can-arrays' script puts the text strings for the buttons in an ## array variable. Then, in a loop over the array argument, the canvases are ## defined-and-packed (with image and text put on each canvas). ## In another loop over the array argument, the bindings are defined. ## ## The 'txt-can-arrays' script also defines the canvas widgets as ## .can(1), .can(2), ... rather than .can1, .can2, ... ## ##+################################################################### ## Created: 2012jul26 ## Changed: 2012aug09 Added DESCRIPTION and REFERENCES sections in ## the comments above. ## Put the creation of the drawers in a 'while' loop ## using arrays for the text strings on the buttons ## and for the button widget IDs --- instead of using ## 'eval' to make the text string vars and button IDs. ##+################################################################### ##+################################################# ## Set window titles, location, and resize behavior. ##+################################################# # wm title . "Toolchest-of-drawers-which-are-button-widgets - Test" # wm iconname . "ToolchestTest" wm title . "Apps Toolchest" wm iconname . "Apps" wm geometry . +150+30 wm resizable . 0 0 ##+###################################### ## Set a color scheme for the toolchest ## --- esp. its buttons, frames, borders. ##+###################################### tk_setPalette "#cc9933" ##+###################################### ## Set font to use in the button widgets. ##+###################################### set feFONT_button "-family {comic sans ms} -size -14 -weight bold -slant roman" eval font create fontTEMP_button $feFONT_button ##+#################################################################### ## Set button (drawer) geometry parameters --- xy padding, borderwidth. ##+#################################################################### set fePADX_button 0 set fePADY_button 0 set feBDwidth_button 0 ##+############################################################# ## Set a bullet image to use on the left of each button (drawer) ## --- for a little decoration. ##+############################################################# # set imgID4bullet [image create photo -file "./bullet_grayish_20x15_transp.gif"] set imgID4bullet [image create photo -file "./bullet_orangish_20x15_transp.gif"] ##+######################################################## ## Define and pack frame(s) to contain the drawers. ## ## We do not define the bottom-config-buttons subframe of ## the left frame. And we do not define the right frame. ## Those are frames used in the full implementation of ## the feAppMenus and feHandyTools FE subsystems. ##+######################################################## ## FOR TESTING: # set feRELIEF_frame raised # set feBDwidth_frame 2 set feRELIEF_frame flat set feBDwidth_frame 0 frame .fRleft -relief $feRELIEF_frame -bd $feBDwidth_frame frame .fRleft.fRdrawers -relief $feRELIEF_frame -bd $feBDwidth_frame pack .fRleft \ -side left \ -anchor nw \ -fill none \ -expand 0 pack .fRleft.fRdrawers \ -side top \ -anchor nw \ -fill both \ -expand 1 ## Other frames in the feAppMenus and feHandyTools toolchest-making scripts: ## ## .fRleft.fRbottom ## .fRright.fRdrawers ## .fRright.fRbottom ##+####################################################### ## Set the text strings to be put on the buttons/drawers ## --- in variables. ## ## We changed ## textSTRING1, textSTRING2, ... ## to array variables ... ## textSTRING(1), textSTRING(2), ... ## ## In a 'production' script, these vars could be set by reading ## lines of a 'chest definition' file, for each toolchest. ##+####################################################### set textSTRING(1) "Seamonkey - web browser" set textSTRING(2) "Thunderbird - email client" set textSTRING(3) "Filezilla - FTP client" set textSTRING(4) "mtpaint - image editor" set Ndrawers 4 ##+####################################################### ## In a loop over the number of drawers, ## define and pack the button widgets (toolchest drawers). ## ## This includes putting the text string on each button, ## putting the 'bullet' image on the left of each drawer, ## and setting a command to use for each drawer. ##+####################################################### set drawerCNT 1 while { $drawerCNT <= $Ndrawers } { set drawerMSG "Toolchest drawer $drawerCNT was clicked" ## FOR TESTING: # puts "drawerMSG: $drawerMSG" button .fRleft.fRdrawers.butt($drawerCNT) \ -text "$textSTRING($drawerCNT)" \ -anchor w \ -font fontTEMP_button \ -relief flat \ -bd $feBDwidth_button \ -padx $fePADX_button \ -pady $fePADY_button \ -image $imgID4bullet \ -compound left \ -command " tk_dialog .dialog1 \ \"Dear user:\" \"$drawerMSG\" info 0 OK " pack .fRleft.fRdrawers.butt($drawerCNT) \ -side top \ -anchor nw \ -fill both \ -expand 1 set drawerCNT [expr $drawerCNT + 1] } ## END OF 'while' LOOP