#!/usr/bin/wish -f ## ##+####################################################################### ## NOTE: ## If the 'wish' interpreter is in another directory, like ## /usr/local/bin, you, as root, can make a soft-link from 'wish' there ## to /usr/bin/wish --- with a command like ## ln -s /usr/bin/local/wish /usr/bin/wish ## The form of this command: ## ln -s ##+####################################################################### ## ## Tk SCRIPT NAME: tkVisualizer_RadialLines.tk ## ## WHERE: in $FEDIR_TKGUIS/ImageAnimations = $FEDIR/tkGUIs/ImageAnimations ## ## where $FEDIR is the installation directory ## of an FE subsystem --- such as 'tkGooies'. ## The default installation directory ## is FEDIR = $HOME/apps/tkGooies. ## Reference: www.freedomenv.com ##+####################################################################### ## PURPOSE: This TkGUI script provides a GUI for implementing a ## 'Visualizer' --- such as an audio 'visualizer' --- ## which shows an animation on a Tk GUI that can be driven ## to change according to an input such as audio input ## (amplitude and/or fequency) or some other varying input, ## such as computer CPU or network-interface usage. ## ## This particular 'visualizer' is named 'tkVisualizer_RadialLines' ## because it draws colored lines of various lengths where the ## lines emanate radially from a central point on a Tk canvas. ## ## The line-segments are created on the canvas using Tk canvas ## 'create line' commands. ## ## The Tcl 'rand' command may be employed to generate some ## randomness in various aspects of the animation, such as ## - line-segment directions (an angle between 0 and 360 degrees) ## - line-segment lengths ## - line-segment colors ## ## This GUI may also have a background-color button by which ## the user can specify the color of the canvas background. ## ## In fact, an option could be provided (via an entry widget ## and a browse-for-file option) so that the user could read ## an image file for the canvas background, to cover or ## partially-cover the canvas background color. ## ## ################ ## IMAGE CAPTURE: ## ## To capture any single image of the text on the canvas, ## the user can use a screen/window capture utility ## (such as 'gnome-screenshot' on Linux) to capture the ## image in an image file format, such as PNG. ## ## An image editor (such as 'mtpaint' on Linux) can be used to ## 'crop' the captured image if necessary --- and can be used ## to apply processing options such as 'blur' or 'emboss' or ## whatever. ## ## The resulting image file(s) can be printed with an image ## view-and-print utility (such as 'eog' = 'Eye of Gnome' on ## Linux). ## ## ------ ## ## A 'WriteAniGIF' button could eventually be provided on the GUI, ## by which to capture a segment of the 'visualizer' animation ## in an animated-GIF file. ## ##+################# ## THE GUI WIDGETS: ## ## The options available to the user are indicated by ## the following 'sketch' of the GUI: ## ## FRAMEnames ## VVVVVVVVVV ## ----------------------------------------------------------------------------------- ## tkVisualizer_RadialLines ## [window title] ## --------------------------------------------------------------------------------- ## ## .fRbuttons {Exit} {Help} {Clear} {Backgd Animate: O Start O Stop Speed of animation 0 500 ## Color} (wait millisecs/line): <-----O----> ## ## .fRfile Background Image filename: __________________________________________ {Browse...} ## ## .fRmsg [.... Messages to user are display in a label here .............................] ## ## Width & height of 10 2000 Driving ## .fRcontrols1 canvas (pixels): <----------O---------> data: O Random O CPU O Network O Audio ## ## |-------------------------------------------------------------------------------A ## .fRcanvas | [CANVAS (scollable) on which to show the | ## | animation of radial lines.] | ## | | ## | | ## | | ## | | ## | | ## |<------------------------------------------------------------------------------>V ## ## ------------------------------------------------------------------- ## ## In the above sketch of the GUI: ## ## SQUARE BRACKETS indicate a comment (not to be placed on the GUI). ## BRACES indicate a Tk 'button' widget. ## A COLON indicates that the text before the colon is on a 'label' widget. ## (To clarify the label extent, single quotes may be used around the text.) ## ## UNDERSCORES indicate a Tk 'entry' widget. ## CAPITAL-O indicates a Tk 'radiobutton' widget. ## CAPITAL-X indicates a Tk 'checkbutton' widget (if any). ## <----O----> indicates a horizontal Tk 'scale' widget. ## ## A rectangle marked by hyphens (-) and vertical bars (|) ## indicates a Tk 'canvas' --- or 'text' or 'listbox' widget. ## ##+############## ## GUI components: ## ## From the GUI 'sketch' above, it is seen that the GUI consists of ## about ## ## - 5 button widgets ## - 4 label widgets ## - 6 radiobutton widgets (in 2 groups) ## (We may add another group of radiobuttons by which the ## user can specify what will drive the 'visualizer' --- ## CPU usage, network-interface usage, audio input, or other. ## - 1 entry widget ## - 1 scale widget (horizontal) ## - 1 canvas widget (with x,y scrollbars) ## - 0 checkbutton widgets ## - 0 listbox widgets ## - 0 text widgets ## ##+##################################################################### ## CALLED BY: an 'ImageAnimations' toolchest of the 'IMAGEtools' toolchest ## in the 'tkGooies' FE system ## OR ## in a shell script or another Tk script. ## ##+######################################################################## ## 'CANONICAL' STRUCTURE OF THIS CODE: ## ## 0) Set general window parms (win-name,win-position,win-color-scheme, ## fonts,widget-geom-parameters,win-size-control,text-array-for-labels-etc). ## 1a) Define ALL frames (and sub-frames). ## 1b) Pack ALL frames and sub-frames. ## 2) Define & pack all widgets in the frames, frame by frame. ## ## 3) Define key and mouse/touchpad/touch-sensitive-screen 'event' ## BINDINGS, if needed. ## 4) Define PROCS, if needed. ## 5) Additional GUI INITIALIZATION (typically with one or two procs ## from section 4), if needed. ## #################################### ## Some detail on the code structure of this particular Tk script: ## ## 1a) Define ALL frames: ## ## Top-level : ## 'fRbuttons' - to contain buttons such as 'Exit', 'Help', ## 'Clear' --- and a color selection button, ## for canvas (background) color. ## Also 2 radiobuttons to start/stop the animation. ## 'fRfile' - to contain a triplet: label-entry-button widgets. ## 'fRmsg' - to contain a label for messages to the user. ## 'fRcontrols1' - to contain a label and a horizontal scale widget. ## 'fRcanvas' - to contain a scrollable canvas widget. ## ## Sub-frames: none ## ## 1b) Pack ALL frames. ## ## 2) Define & pack all widgets in the frames -- basically going through ## frames & their interiors in top-to-bottom and/or left-to-right order: ## ## 3) Define bindings: ## ## - bind - on the listbox widget - calls proc 'listbox_select' ## ## 4) Define procs: ## - 'get_img_filename' - to get the image filename, ## called by the Browse button. ## ## - 'add_image' - to add an image to the canvas as a background, ## called by a button1-release binding on the ## image filename entry field. ## ## - 'animate' - to draw 'radial colored lines' on the canvas, ## called by a button1-release binding on the ## 'Start' radiobutton. ## ## - 'clear' - to remove all objects from the canvas (lines & img), ## called by the 'Clear' button. ## ## - 'set_background_color' - to set the background (canvas) color. ## ## - 'set_background_button_color' - to set the background and foreground colors ## of the color button. ## ## - 'advise_user' - to put messages in the fRmsg frame, ## called in the 'animate' proc and maybe elsewhere. ## ## - 'popup_msg_var_scroll' - to show the text of the HELPtext variable in a ## popup window, called by the 'Help' button. ## ## 5) Additional GUI initialization: ## - set an initial canvas background color ## ## Other than the background color, the canvas is blank, ## waiting for the user to (optionally) select a background image and to ## start the animation with a click on the Start radiobutton. ## ##+####################################################################### ## DEVELOPED WITH: Tcl-Tk 8.5 on Ubuntu 9.10 (2009-october, 'Karmic Koala') ## ## $ wish ## % puts "$tcl_version $tk_version" ## ## showed ## 8.5 8.5 ## but this script should work in most previous 8.x versions, and probably ## even in some 7.x versions (if font handling is made 'old-style'). ##+######################################################################## ## MAINTENANCE HISTORY: ## Started by: Blaise Montandon 2016apr12 ## Changed by: Blaise Montandon 2016 ##+####################################################################### ##+####################################################################### ## Set general window parms (titles,position). ##+####################################################################### wm title . "tkVisualizer_RadialLines" wm iconname . "VisualizerRadial" wm geometry . +15+30 ##+###################################################### ## Set the color scheme for the window and its widgets --- ## such as entry field background color. ##+###################################################### tk_setPalette "#e0e0e0" set entryBKGD "#ffffff" set radbuttBKGD "#f0f0f0" # set textBKGD "#ffffff" # set listboxBKGD "#ffffff" ##+######################################################## ## We use a VARIABLE-WIDTH font for text on label and ## button widgets. ## ## We use a FIXED-WIDTH font for text in entry & listbox widgets ## and for the text in a text widget, such as help text. ##+######################################################## font create fontTEMP_varwidth \ -family {comic sans ms} \ -size -14 \ -weight bold \ -slant roman font create fontTEMP_SMALL_varwidth \ -family {comic sans ms} \ -size -10 \ -weight bold \ -slant roman ## Some other possible (similar) variable width fonts: ## Arial ## Bitstream Vera Sans ## DejaVu Sans ## Droid Sans ## FreeSans ## Liberation Sans ## Nimbus Sans L ## Trebuchet MS ## Verdana font create fontTEMP_fixedwidth \ -family {liberation mono} \ -size -14 \ -weight bold \ -slant roman font create fontTEMP_SMALL_fixedwidth \ -family {liberation mono} \ -size -10 \ -weight bold \ -slant roman ## Some other possible fixed width fonts (esp. on Linux): ## Andale Mono ## Bitstream Vera Sans Mono ## Courier 10 Pitch ## DejaVu Sans Mono ## Droid Sans Mono ## FreeMono ## Nimbus Mono L ## TlwgMono ##+########################################################### ## SET GEOM VARS FOR THE VARIOUS WIDGET DEFINITIONS. ## (e.g. width and height of canvas, and padding for Buttons) ##+########################################################### ## BUTTON widget geom settings: set PADXpx_button 0 set PADYpx_button 0 set BDwidthPx_button 2 ## LABEL widget geom settings: set RELIEF_label "flat" set BDwidthPx_label 2 ## RADIOBUTTON widget geom settings: set RELIEF_radbutt "ridge" # set PADXpx_radbutt 0 # set PADYpx_radbutt 0 set BDwidthPx_radbutt 2 ## ENTRY widget geom settings: set BDwidthPx_entry 2 set initImgfileEntryWidthChars 20 ## SCALE geom parameters: set BDwidthPx_scale 2 set initScaleLengthPx 200 ## CANVAS geom settings: set initCanWidthPx 500 set initCanHeightPx 500 set minCanWidthPx 24 set minCanHeightPx 24 # set BDwidthPx_canvas 2 set BDwidthPx_canvas 0 ## LISTBOX geom settings: # set BDwidthPx_listbox 2 # set initListboxWidthChars 30 # set initListboxHeightChars 8 ##+######################################################################## ## Set a TEXT-ARRAY to hold text for buttons & labels on the GUI. ## NOTE: This can aid INTERNATIONALIZATION. This array can ## be set according to a nation/region parameter. ##+######################################################################## ## if { "$VARlocale" == "en"} ## For '.fRbuttons' frame: set aRtext(buttonEXIT) "Exit" set aRtext(buttonHELP) "Help" set aRtext(buttonCLEAR) "Clear" set aRtext(buttonCOLORBKGD) "Backgd Color" set aRtext(labelANIMATE) " Animate:" set aRtext(radbuttSTART) "Start" set aRtext(radbuttSTOP) "Stop" set aRtext(labelSPEED) " Speed of animation (wait millisecs/line):" ## For top of '.fRfile' frame: set aRtext(labelFILENAME) "Backgd Image filename:" ## For top of '.fRcontrols1' frame: set aRtext(labelIMGSIZE) "Width & height of image area (pixels):" set aRtext(labelDRIVER) " Driving data:" set aRtext(radbuttRANDOM) "Random" set aRtext(radbuttCPU) "CPU" set aRtext(radbuttNETWORK) "Network" set aRtext(radbuttAUDIO) "Audio" ## END OF if { "$VARlocale" == "en" ##+####################################################################### ## Set a MINSIZE of the window (roughly). ## ## For width, allow for the minwidth of the '.fRbuttons' frame: ## about 7 buttons (Exit,Help,Clear,BkgndColor), ## and a label preceding 2 start-stop radiobuttons. ## ## For height, allow for ## 2 chars high for the widgets in the '.fRbuttons' frame ## 1 char high for the '.fRfile' frame ## 1 char high for the '.fRmsg' frame ## 2 char high for the '.fRcontrols1' frame ## a canvas at least 24 pixels high. ##+####################################################################### set minWinWidthPx [font measure fontTEMP_varwidth \ "Exit Help Clear Backgd Animate: O Start O Stop"] ## Add some pixels to account for right-and-left-side window decoration ## (about 8 pixels), about 7 x 4 pixels/widget for borders/padding for ## 7 widgets. set minWinWidthPx [expr {36 + $minWinWidthPx}] ## MIN HEIGHT --- ## for the 5 frames 'fRbuttons' 'fRfile' 'fRmsg' ## 'fRcontrols1' 'fRcanvas'. ## Allow ## 2 chars high for 'fRbuttons' ## 1 char high for 'fRfile' ## 1 char high for 'fRmsg' ## 2 chars high for 'fRcontrols1' ## 24 pixels high for 'fRcanvas' set charHeightPx [font metrics fontTEMP_fixedwidth -linespace] set minWinHeightPx [expr {24 + (6 * $charHeightPx)}] ## Add about 28 pixels for top-bottom window decoration, ## about 5x4 pixels for each of the 5 stacked frames and their ## widgets (their borders/padding). set minWinHeightPx [expr {$minWinHeightPx + 48}] ## FOR TESTING: # puts "minWinWidthPx = $minWinWidthPx" # puts "minWinHeightPx = $minWinHeightPx" wm minsize . $minWinWidthPx $minWinHeightPx ## We allow the window to be resizable and we pack the canvas with ## '-fill both' so that the canvas can be enlarged by enlarging the ## window. ## If you want to make the window un-resizable, ## you can use the following statement. # wm resizable . 0 0 ##+################################################################ ## DEFINE *ALL* THE FRAMES: ## ## Top-level : '.fRbuttons' '.fRfile' '.fRmsg' ## '.fRcontrols1' '.fRcanvas' ## ## Sub-frames: none ##+################################################################ ## FOR TESTING change 0 to 1: ## (Example1: To see appearance of frames when borders are drawn.) ## (Example2: To see sizes of frames for various '-fill' options.) ## (Example3: To see how frames expand as window is resized.) if {0} { set RELIEF_frame raised set BDwidthPx_frame 2 } else { set RELIEF_frame flat set BDwidthPx_frame 0 } frame .fRbuttons -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRfile -relief $RELIEF_frame -bd $BDwidthPx_frame # frame .fRmsg -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRmsg -relief raised -bd 2 frame .fRcontrols1 -relief $RELIEF_frame -bd $BDwidthPx_frame frame .fRcanvas -relief raised -bd 2 ##+###################################### ## PACK the FRAMES. ## NOTE: We can experiment with the order ## in which the frames are stacked. ##+###################################### pack .fRbuttons \ -side top \ -anchor nw \ -fill none \ -expand 0 pack .fRfile \ -side top \ -anchor nw \ -fill x \ -expand 0 pack .fRmsg \ -side top \ -anchor nw \ -fill x \ -expand 1 pack .fRcontrols1 \ -side top \ -anchor nw \ -fill x \ -expand 0 pack .fRcanvas \ -side top \ -anchor n \ -fill none \ -expand 0 ##+######################################### ## OK, frames are defined. ## Now start defining-and-packing widgets. ##+######################################### ##+######################################### ## In FRAME '.fRbuttons' - ## DEFINE several BUTTON and RADIOBUTTON widgets. ## Then PACK them. ##+######################################### button .fRbuttons.buttEXIT \ -text "$aRtext(buttonEXIT)" \ -font fontTEMP_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command {exit} button .fRbuttons.buttHELP \ -text "$aRtext(buttonHELP)" \ -font fontTEMP_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command {popup_msg_var_scroll "$HELPtext"} button .fRbuttons.buttCLEAR \ -text "$aRtext(buttonCLEAR)" \ -font fontTEMP_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command {clear} button .fRbuttons.buttCOLORBKGD \ -text "$aRtext(buttonCOLORBKGD)" \ -font fontTEMP_SMALL_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command "set_background_color" label .fRbuttons.labelANIMATE \ -text "$aRtext(labelANIMATE)" \ -font fontTEMP_varwidth \ -justify left \ -anchor w \ -relief $RELIEF_label \ -bd $BDwidthPx_label set VARstartORstop "stop" radiobutton .fRbuttons.radbuttSTART \ -text "$aRtext(radbuttSTART)" \ -font fontTEMP_varwidth \ -anchor w \ -variable VARstartORstop \ -value "start" \ -selectcolor "$radbuttBKGD" \ -relief $RELIEF_radbutt \ -bd $BDwidthPx_radbutt radiobutton .fRbuttons.radbuttSTOP \ -text "$aRtext(radbuttSTOP)" \ -font fontTEMP_varwidth \ -anchor w \ -variable VARstartORstop \ -value "stop" \ -selectcolor "$radbuttBKGD" \ -relief $RELIEF_radbutt \ -bd $BDwidthPx_radbutt label .fRbuttons.labelSPEED \ -text "$aRtext(labelSPEED)" \ -font fontTEMP_varwidth \ -justify left \ -anchor w \ -relief $RELIEF_label \ -bd $BDwidthPx_label ## We will set 'WAITmillisecs' (the scale variable) in the ## GUI-init section at the bottom of this script. ## # set WAITmillisecs 2 scale .fRbuttons.scaleSPEED \ -orient horizontal \ -resolution 1 \ -from 0 -to 500 \ -digits 0 \ -length $initScaleLengthPx \ -repeatdelay 1000 \ -font fontTEMP_varwidth \ -variable WAITmillisecs ## Pack ALL the widgets in frame 'fRbuttons'. pack .fRbuttons.buttEXIT \ .fRbuttons.buttHELP \ .fRbuttons.buttCLEAR \ .fRbuttons.buttCOLORBKGD \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRbuttons.labelANIMATE \ .fRbuttons.radbuttSTART \ .fRbuttons.radbuttSTOP \ -side left \ -anchor w \ -fill x \ -expand 0 pack .fRbuttons.labelSPEED \ .fRbuttons.scaleSPEED \ -side left \ -anchor w \ -fill none \ -expand 0 ##+############################### ## In FRAME '.fRfile' - ## DEFINE 3 widgets - LABEL, ENTRY, BUTTON. ## Then PACK them. ##+############################### label .fRfile.labelFILE \ -text "$aRtext(labelFILENAME)" \ -font fontTEMP_varwidth \ -justify left \ -anchor w \ -relief $RELIEF_label \ -bd 0 ## We initialize this widget var (and others) ## in the GUI initialization section at the ## bottom of this script. ## # set ENTRYfilename "" entry .fRfile.entFILENAME \ -textvariable ENTRYfilename \ -bg $entryBKGD \ -font fontTEMP_fixedwidth \ -width $initImgfileEntryWidthChars \ -relief sunken \ -bd $BDwidthPx_entry button .fRfile.buttBROWSE \ -text "Browse ..." \ -font fontTEMP_varwidth \ -padx $PADXpx_button \ -pady $PADYpx_button \ -relief raised \ -bd $BDwidthPx_button \ -command {get_img_filename} ## Pack ALL the widgets in frame 'fRfile'. pack .fRfile.labelFILE \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRfile.entFILENAME \ -side left \ -anchor w \ -fill x \ -expand 1 pack .fRfile.buttBROWSE \ -side left \ -anchor w \ -fill none \ -expand 0 ##+######################################### ## In FRAME '.fRmsg' - ## DEFINE a LABEL widget. Then PACK it. ##+######################################### label .fRmsg.labelMSG \ -text "" \ -font fontTEMP_varwidth \ -justify left \ -anchor w \ -relief $RELIEF_label \ -bd $BDwidthPx_label ## Pack the widgets in frame 'fRstatus'. pack .fRmsg.labelMSG \ -side left \ -anchor w \ -fill x \ -expand 1 ##+################################################### ## In FRAME '.fRcontrols1' - ## DEFINE a LABEL and SCALE widget. Then PACK them. ##+################################################### label .fRcontrols1.labelIMGSIZE \ -text "$aRtext(labelIMGSIZE)" \ -font fontTEMP_varwidth \ -justify left \ -anchor w \ -relief $RELIEF_label \ -bd $BDwidthPx_label ## We will set 'VARimgsizePx' (the scale variable) in the ## GUI-init section at the bottom of this script. ## # set VARimgsizePx 400 scale .fRcontrols1.scaleIMGSIZE \ -orient horizontal \ -resolution 1 \ -from 100 -to 2000 \ -digits 0 \ -length $initScaleLengthPx \ -repeatdelay 1000 \ -font fontTEMP_varwidth \ -variable VARimgsizePx label .fRcontrols1.labelDRIVER \ -text "$aRtext(labelDRIVER)" \ -font fontTEMP_varwidth \ -justify left \ -anchor w \ -relief $RELIEF_label \ -bd $BDwidthPx_label set VARdriver "random" radiobutton .fRcontrols1.radbuttRANDOM \ -text "$aRtext(radbuttRANDOM)" \ -font fontTEMP_varwidth \ -anchor w \ -variable VARdriver \ -value "random" \ -selectcolor "$radbuttBKGD" \ -relief $RELIEF_radbutt \ -bd $BDwidthPx_radbutt radiobutton .fRcontrols1.radbuttCPU \ -text "$aRtext(radbuttCPU)" \ -font fontTEMP_varwidth \ -anchor w \ -variable VARdriver \ -value "cpu" \ -selectcolor "$radbuttBKGD" \ -relief $RELIEF_radbutt \ -bd $BDwidthPx_radbutt radiobutton .fRcontrols1.radbuttNETWORK \ -text "$aRtext(radbuttNETWORK)" \ -font fontTEMP_varwidth \ -anchor w \ -variable VARdriver \ -value "network" \ -selectcolor "$radbuttBKGD" \ -relief $RELIEF_radbutt \ -bd $BDwidthPx_radbutt radiobutton .fRcontrols1.radbuttAUDIO \ -text "$aRtext(radbuttAUDIO)" \ -font fontTEMP_varwidth \ -anchor w \ -variable VARdriver \ -value "audio" \ -selectcolor "$radbuttBKGD" \ -relief $RELIEF_radbutt \ -bd $BDwidthPx_radbutt ## Pack the widgets in frame 'fRcontrols1'. pack .fRcontrols1.labelIMGSIZE \ .fRcontrols1.scaleIMGSIZE \ -side left \ -anchor w \ -fill none \ -expand 0 pack .fRcontrols1.labelDRIVER \ .fRcontrols1.radbuttRANDOM \ .fRcontrols1.radbuttCPU \ .fRcontrols1.radbuttNETWORK \ .fRcontrols1.radbuttAUDIO \ -side left \ -anchor w \ -fill x \ -expand 0 ##+################################################### ## In FRAME '.fRcanvas' - ## DEFINE a CANVAS widget with 2 scrollbars. ## Then PACK them. ##+################################################### ## We set '-highlightthickness' and '-borderwidth' to ## zero, to avoid covering some of the viewable area ## of the canvas, as suggested on page 558 of the 4th ## edition of 'Practical Programming with Tcl and Tk'. ##+################################################### canvas .fRcanvas.can \ -width $initCanWidthPx \ -height $initCanHeightPx \ -relief flat \ -highlightthickness 0 \ -borderwidth 0 \ -yscrollcommand ".fRcanvas.scrolly set" \ -xscrollcommand ".fRcanvas.scrollx set" scrollbar .fRcanvas.scrolly \ -orient vertical \ -command ".fRcanvas.can yview" scrollbar .fRcanvas.scrollx \ -orient horizontal \ -command ".fRcanvas.can xview" ## Pack ALL the '.fRcanvas' widgets (scrollbars and canvas). ## NOTE: ## GOOD TO PACK THE SCROLLBARS BEFORE THE CANVAS WIDGET. ## THE CANVAS WIDGET MAY TRY TO TAKE ALL THE FRAME SPACE. pack .fRcanvas.scrolly \ -side right \ -anchor e \ -fill y \ -expand 0 ## DO NOT USE '-expand 1' FOR Y-SCROLLBAR. IT ALLOWS Y-SCROLLBAR ## TO X-EXPAND. IT PUTS BLANK SPACE BETWEEN Y-SCROLLBAR & CANVAS. pack .fRcanvas.scrollx \ -side bottom \ -anchor s \ -fill x \ -expand 0 ## DO NOT USE '-expand 1' FOR X-SCROLLBAR. IT ALLOWS X-SCROLLBAR ## TO Y-EXPAND. IT KEEPS THE CANVAS FROM Y-EXPANDING. pack .fRcanvas.can \ -side top \ -anchor nw \ -fill both \ -expand 1 ##+################################################## ## END OF DEFINITION of the GUI widgets. ##+################################################## ## Start of BINDINGS, PROCS, Added-GUI-INIT sections. ##+################################################## ##+####################################################################### ##+####################################################################### ## BINDINGS SECTION: ## - on the Start radiobutton ## - on the ImageFilename entry field ##+####################################################################### ## For Start radiobutton: bind .fRbuttons.radbuttSTART { animate } ## For ImgSize scale widget: bind .fRcontrols1.scaleIMGSIZE { .fRcanvas.can configure -width $VARimgsizePx -height $VARimgsizePx .fRcanvas.can configure -scrollregion "0 0 $VARimgsizePx $VARimgsizePx" ## (We use a 'wm' command to get the window to resize ## according to the canvas resize --- even after the ## user has manually resized the top window.) wm geometry . {} clear } ## For filename-entry-field: bind .fRfile.entFILENAME { add_image } bind .fRfile.entFILENAME { add_image } ##+############################################################################# ##+############################################################################# ## DEFINE PROCS SECTION: ## ## - 'get_img_filename' - gets the filename of an image (GIF/PNG) file ## and places the image on the canvas ## ## - 'add_image' - puts an image from the image-filename in the ## filename-entry-field onto the canvas ## ## - 'animate' - to draw 'radial colored lines' on the canvas, ## called by a button1-release binding on the ## 'Start' radiobutton. ## ## - 'set_background_color' - set the background (canvas) color ## ## - 'set_background_button_color' - updates the background & foreground colors ## on the canvas-background color button. ## ## - 'clear' - removes all objects from the canvas (lines & img) ## ## - 'advise_user' - called by some bindings, and called in the ## 'Additional GUI Initialization' section at ## the bottom of the script. ## ## - 'popup_msg_var_scroll' - to show help in the HELPtext variable, ## and to show other msgs as needed ##+############################################################################ ##+######################################################################### ## proc 'get_img_filename' ############################################################################ ## PURPOSE: To get the name of an image file (GIF/PNG) and put the ## filename into global var 'ENTRYfilename'. ## ## Also, go ahead and load the image onto the canvas. (?) ## ## USED BY: the '-command' option of the 'Browse ...' button. ##+######################################################################### proc get_img_filename {} { global ENTRYfilename env curDIR imgID ## Provide the user a way to select an image file. set fName [tk_getOpenFile -parent . -title "Select GIF/PNG file to load" \ -initialdir "$curDIR" ] ## FOR TESTING: # puts "fName : $fName" ## Set variables ENTRYfilename and curDIR. if {[file exists $fName]} { set ENTRYfilename "$fName" set curDIR [ file dirname "$ENTRYfilename" ] ## Put the end of the filename in view. .fRfile.entFILENAME xview end ## Display a starting-animation message to the user. advise_user "**** Use the Enter key (or 'right-click' on the filename) to \ put the image on the canvas. ****" } ## END OF if {[file exists $fName]} } ## END OF PROC 'get_img_filename' ##+################################################################## ## proc 'add_image' ##+################################################################## ## PURPOSE: Puts an image on the canvas (in the upper left corner) ## based on the image filename currently in the ## image-filename-entry-field. ## ## CALLED BY: two bindings on the image-filename-entry-field --- ## one binding for Return-key and one for button1-release. ##+################################################################## proc add_image {} { global ENTRYfilename imgID VARimgsizePx ## Remove a previously created image, if any, from memory. catch { image delete imgID } ## Create a new in-memory image from the current filename. set imgID [image create photo -file "$ENTRYfilename"] ## Reset the canvas size to VARimgsize (formerly the image size). set imgWidthPx [image width $imgID] set imgHeightPx [image height $imgID] # .fRcanvas.can configure -width $imgWidthPx -height $imgHeightPx .fRcanvas.can configure -width $VARimgsizePx -height $VARimgsizePx ## Get the middle of the canvas area. # set curCanWidthPx [winfo width .fRcanvas.can] # set halfCanWidthPx [expr {$curCanWidthPx/2}] set halfCanWidthPx [expr {$VARimgsizePx/2}] # set curCanHeightPx [winfo height .fRcanvas.can] # set halfCanHeightPx [expr {$curCanHeightPx/2}] set halfCanHeightPx [expr {$VARimgsizePx/2}] ## FOR TESTING: if {0} { puts "" puts "add_image:" puts "imgWidthPx: $imgWidthPx" puts "imgHeightPx: $imgHeightPx" puts "VARimgsizePx: $VARimgsizePx" # puts "curCanWidthPx: $curCanWidthPx" # puts "curCanHeightPx: $curCanHeightPx" puts "halfCanWidthPx: $halfCanWidthPx" puts "halfCanHeightPx: $halfCanHeightPx" puts "" } ## Put the image on the canvas --- anchoring the center ## of the image to the center of the canvas ## (formerly the top-left corner of the image to the top-left corner of the canvas ## (formerly top-middle of the image to the top middle of the canvas). .fRcanvas.can create image $halfCanWidthPx $halfCanHeightPx -anchor center \ -image $imgID -tag TAGimg # .fRcanvas.can create image 0 0 -anchor nw \ # -image $imgID -tag TAGimg # .fRcanvas.can create image $halfCanWidthPx 0 -anchor n \ # -image $imgID -tag TAGimg } ## END OF PROC 'add_image' ##+##################################################################### ## PROC 'animate' ##+##################################################################### ## PURPOSE: Draw 'radial colored lines' on the canvas. ## ## CALLED BY: a button1-release binding on the 'Start' radiobutton. ##+##################################################################### proc animate {} { ## FOR TESTING: (to dummy out this proc) # return global VARdriver DIRthisScript VARstartORstop WAITmillisecs \ VARimgsizePx lineMAXWIDTHpx pi \ COLORBKGDr COLORBKGDg COLORBKGDb COLORBKGDhex imgID ## Set the current time, for determining elapsed ## time for building each 'photo' image. (Not used - yet.) # set t0 [clock milliseconds] ## Display a starting-animation message to the user. advise_user "** Starting animation. Click 'Stop' to halt the processing \ or click 'Clear' to remove all lines. **" ####################################################### ## If an image was loaded to the canvas, let the image ## determine the size of the (scrollable) canvas area. ####################################################### if {[info exists imgID]} { ######################################################## ## Set the 'scrollregion' of the canvas according to the ## VARimgsizePx variable (formerly to the size of the image). ## (A simple 'update' does not work.) ######################################################## set imgWidthPx [image width $imgID] set imgHeightPx [image height $imgID] # .fRcanvas.can configure -scrollregion "0 0 $imgWidthPx $imgHeightPx" .fRcanvas.can configure -scrollregion "0 0 $VARimgsizePx $VARimgsizePx" ## FOR TESTING: if {0} { puts "" puts "animate -- image-exists section:" puts "imgWidthPx: $imgWidthPx" puts "imgHeightPx: $imgHeightPx" puts "VARimgsizePx: $VARimgsizePx" puts "" } ######################################################## ## Make the canvas area as big as we can to accomodate ## VARimgsizePx (formerly the image size). ## (We use a 'wm' command to get the window to resize ## according to the canvas resize --- even after the ## user has manually resized the top window.) ######################################################## # wm geometry . {} ;# from wiki.tcl.tk/10720 and wiki.tcl.tk/44 ; WORKS! # .fRcanvas.can configure -width $imgWidthPx -height $imgHeightPx .fRcanvas.can configure -width $VARimgsizePx -height $VARimgsizePx wm geometry . {} ;# WORKS here too. } ## END OF if {[info exists imgID]} ######################################################### ## Get the current canvas width and height. ######################################################### set curCanWidthPx [winfo reqwidth .fRcanvas.can] set curCanHeightPx [winfo reqheight .fRcanvas.can] ####################################################### ## Initialize the location variables for center of ## the canvas/image area. ####################################################### set halfCanWidthPx [expr {$curCanWidthPx/2}] set halfCanHeightPx [expr {$curCanHeightPx/2}] ####################################################### ## Set maximum radial dimension. ####################################################### set maxRADIUSpx $halfCanWidthPx if {$halfCanHeightPx < $maxRADIUSpx} {set maxRADIUSpx $halfCanHeightPx} ## FOR TESTING: if {0} { puts "" puts "animate:" puts "curCanWidthPx: $curCanWidthPx" puts "curCanHeightPx: $curCanHeightPx" puts "halfCanWidthPx: $halfCanWidthPx" puts "halfCanHeightPx: $halfCanHeightPx" puts "maxRADIUSpx: $maxRADIUSpx" puts "" } ####################################################### ## Remove any previously drawn line(s) from the canvas. ####################################################### .fRcanvas.can delete TAGline ################################################################### ## A 'while' LOOP to draw the (radial) lines, ## until STOP is signalled. ################################################################### while {true} { ####################################################### ## Get a 'driving number' from the user-selected ## 'driver source'. ## ## We assume this number is confined between 0 and 100. ####################################################### if {"$VARdriver" == "random"} { set DRIVERnum [expr {100.0 * rand()}] } elseif {"$VARdriver" == "cpu"} { set DRIVERnum [exec "$DIRthisScript/get_from_cpu.sh"] } elseif {"$VARdriver" == "network"} { set DRIVERnum [exec "$DIRthisScript/get_from_network.sh"] } elseif {"$VARdriver" == "audio"} { set DRIVERnum [exec "$DIRthisScript/get_from_audio.sh"] } ####################################################### ## Calculate a random angle (between 0 and 2*pi) ## with which to draw the next line segment. ####################################################### set randANGLErads [expr {2.0 * $pi * rand()}] ########################################################### ## Calculate a random width (in pixels) for the next ## line segment. ## ## Use the variables lineMAXWIDTHpx (between 1 and about 6) ## and DRIVERnum (between 0 and 100) to determine the width. ########################################################### set tempLINEWIDTHpx [expr {int( ($DRIVERnum/100.0) * $lineMAXWIDTHpx * rand() )}] incr tempLINEWIDTHpx ####################################################### ## Calculate 2 random radial distances with which ## to draw the next line segment. ## ## Use the variables maxRADIUSpx and ## DRIVERnum (between 0 and 100) to determine the width. ####################################################### set tempRADIUS1px [expr {int( ($DRIVERnum/100.0) * $maxRADIUSpx * rand() )}] set tempRADIUS2px [expr {int( ($DRIVERnum/100.0) * $maxRADIUSpx * rand() )}] ####################################################### ## Calculate 2 pairs of x,y coordinates, using the ## angle $randANGLErads and the two radiuses ## $tempRADIUS1px and $tempRADIUS1px. ####################################################### set x1 [expr {($tempRADIUS1px * cos($randANGLErads)) + $halfCanWidthPx}] set y1 [expr {($tempRADIUS1px * sin($randANGLErads)) + $halfCanHeightPx}] set x2 [expr {($tempRADIUS2px * cos($randANGLErads)) + $halfCanWidthPx}] set y2 [expr {($tempRADIUS2px * sin($randANGLErads)) + $halfCanHeightPx}] ####################################################### ## Calculate a random color for the next line. ####################################################### set R0to255 [expr {int( 255 * rand() )}] set G0to255 [expr {int( 255 * rand() )}] set B0to255 [expr {int( 255 * rand() )}] set LINECOLORhex \ [format "#%02X%02X%02X" $R0to255 $G0to255 $B0to255] ## FOR TESTING: if {0} { puts "" puts "animate:" puts "x1: $x1 y1: $y1" puts "x2: $x2 y2: $y2" puts "tempLINEWIDTHpx: $tempLINEWIDTHpx" puts "LINECOLORhex: $LINECOLORhex" } ####################################################### ## Put a radial line in a new position on the canvas. ####################################################### .fRcanvas.can create line \ $x1 $y1 $x2 $y2 \ -width $tempLINEWIDTHpx -fill $LINECOLORhex \ -joinstyle round -capstyle round -tags TAGline # -smooth 1 ####################################################### ## Update the window to cause the line to be displayed. ####################################################### update ####################################################### ## Check if the user has asked to STOP the animation. ## If so, break out of the while loop. ####################################################### if {"$VARstartORstop" == "stop"} { advise_user \ "** Click 'Start' - after, optionally, setting \ background color (or image), the driving data, other options. **" break } ####################################################### ## Pause the amount indicated by the scale widget. ####################################################### after $WAITmillisecs } ## END OF 'while' loop } ## END OF PROC 'animate' ##+##################################################################### ## proc 'set_background_color' ##+##################################################################### ## PURPOSE: This procedure is invoked to get an RGB triplet ## via 3 RGB slider bars on the FE Color Selector GUI. ## ## Uses that RGB value to set the color of the canvas --- ## on which all the objects (lines & image) lie. ## ## ARGUMENTS: none ## ## OUTPUT: in global vars COLORBKGDr COLORBKGDg COLORBKGDb COLORBKGDhex ## ## CALLED BY: .fRbuttons.buttCOLORBKGD button ##+##################################################################### proc set_background_color {} { global COLORBKGDr COLORBKGDg COLORBKGDb COLORBKGDhex ColorSelectorScript ## FOR TESTING: # puts "COLORBKGDr: $COLORBKGDr" # puts "COLORBKGDg: $COLORBKGDb" # puts "COLORBKGDb: $COLORBKGDb" set TEMPrgb [ exec $ColorSelectorScript $COLORBKGDr $COLORBKGDg $COLORBKGDb] ## FOR TESTING: # puts "TEMPrgb: $TEMPrgb" if { "$TEMPrgb" == "" } { return } scan $TEMPrgb "%s %s %s %s" r255 g255 b255 hexRGB set COLORBKGDhex "#$hexRGB" set COLORBKGDr $r255 set COLORBKGDg $g255 set COLORBKGDb $b255 ## Set the color of the canvas. .fRcanvas.can config -bg $COLORBKGDhex ## Update the colors of the background-color button. set_background_button_color } ## END OF PROC 'set_background_color' ##+##################################################################### ## proc 'set_background_button_color' ##+##################################################################### ## PURPOSE: ## Update the background (and foreground) color of the background-button. ## ## CALLED BY: proc 'set_background_color' and the GUI-init section at the ## bottom of this script. ####################################################################### proc set_background_button_color {} { global COLORBKGDr COLORBKGDg COLORBKGDb COLORBKGDhex .fRbuttons.buttCOLORBKGD configure -bg $COLORBKGDhex .fRbuttons.buttCOLORBKGD configure -activebackground $COLORBKGDhex set RGBsum [expr {$COLORBKGDr + $COLORBKGDg + $COLORBKGDb}] if { $RGBsum < 255 } { .fRbuttons.buttCOLORBKGD configure -fg "#f0f0f0" .fRbuttons.buttCOLORBKGD configure -activeforeground "#f0f0f0" } else { .fRbuttons.buttCOLORBKGD configure -fg "#000000" .fRbuttons.buttCOLORBKGD configure -activeforeground "#000000" } } ## END OF proc 'set_background_button_color' ##+##################################################################### ## proc 'clear' ##+##################################################################### ## PURPOSE: Removes all objects (lines and image) from the canvas. ## ## ARGUMENTS: none ## ## CALLED BY: a 'Clear' button. ##+##################################################################### proc clear {} { global VARstartORstop .fRcanvas.can delete all if {"$VARstartORstop" == "stop"} { advise_user "** Click 'Start' to start the animation. Reload the image, if wanted. **" } else { advise_user "** Click 'Stop' to halt the processing. Reload the image, if wanted. **" } } ## END OF proc 'clear' ##+##################################################################### ## proc 'advise_user' ##+##################################################################### ## PURPOSE: Put a message to the user on a label-line of the GUI. ## ## CALLED BY: in some bindings and in the 'Additional GUI Initialization' ## section at the bottom of the script. ##+##################################################################### proc advise_user {text} { .fRmsg.labelMSG configure -text "$text" } ## END OF proc 'advise_user' ##+######################################################################## ## PROC 'popup_msg_var_scroll' ##+######################################################################## ## PURPOSE: Report help or error conditions to the user. ## CALLED BY: 'help' button ##+######################################################################## ## To have more control over the formatting of the message (esp. ## words per line), we use this 'toplevel-text' method, ## rather than the 'tk_dialog' method -- like on page 574 of the book ## by Hattie Schroeder & Mike Doyel,'Interactive Web Applications ## with Tcl/Tk', Appendix A "ED, the Tcl Code Editor". ##+######################################################################## proc popup_msg_var_scroll { VARtext } { ## global fontTEMP_varwidth #; Not needed. 'wish' makes this global. ## global env # bell # bell ################################################# ## Set VARwidth & VARheight from $VARtext. ################################################# ## To get VARheight, ## split at '\n' (newlines) and count 'lines'. ################################################# set VARlist [ split $VARtext "\n" ] ## For testing: # puts "VARlist: $VARlist" set VARheight [ llength $VARlist ] ## For testing: # puts "VARheight: $VARheight" ################################################# ## To get VARwidth, ## loop through the 'lines' getting length ## of each; save max. ################################################# set VARwidth 0 ############################################# ## LOOK AT EACH LINE IN THE LIST. ############################################# foreach line $VARlist { ############################################# ## Get the length of the line. ############################################# set LINEwidth [ string length $line ] if { $LINEwidth > $VARwidth } { set VARwidth $LINEwidth } } ## END OF foreach line $VARlist ## For testing: # puts "VARwidth: $VARwidth" ############################################################### ## NOTE: VARwidth works for a fixed-width font used for the ## text widget ... BUT the programmer may need to be ## careful that the contents of VARtext are all ## countable characters by the 'string length' command. ############################################################### ##################################### ## SETUP 'TOP LEVEL' HELP WINDOW. ##################################### catch {destroy .topmsg} toplevel .topmsg # wm geometry .topmsg 600x400+100+50 wm geometry .topmsg +100+50 wm title .topmsg "Note" # wm title .topmsg "Note to $env(USER)" wm iconname .topmsg "Note" ##################################### ## DEFINE & PACK TEXT WIDGET. ##################################### text .topmsg.text \ -wrap none \ -font fontTEMP_varwidth \ -width $VARwidth \ -height $VARheight \ -bg "#f0f0f0" \ -relief raised \ -bd 2 \ -yscrollcommand ".topmsg.scrolly set" \ -xscrollcommand ".topmsg.scrollx set" scrollbar .topmsg.scrolly \ -orient vertical \ -command ".topmsg.text yview" scrollbar .topmsg.scrollx \ -orient horizontal \ -command ".topmsg.text xview" ## Pack the scrollbars BEFORE the text widget, ## so that the text does not monopolize the space. pack .topmsg.scrolly \ -side right \ -anchor center \ -fill y \ -expand 0 ## DO NOT USE '-expand 1' HERE on the Y-scrollbar. ## THAT ALLOWS Y-SCROLLBAR TO EXPAND AND PUTS ## BLANK SPACE BETWEEN Y-SCROLLBAR & THE TEXT AREA. pack .topmsg.scrollx \ -side bottom \ -anchor center \ -fill x \ -expand 0 ## DO NOT USE '-expand 1' HERE on the X-scrollbar. ## THAT KEEPS THE TEXT AREA FROM EXPANDING. pack .topmsg.text \ -side top \ -anchor center \ -fill both \ -expand 1 ##################################### ## DEFINE & PACK OK BUTTON WIDGET. ##################################### button .topmsg.butt \ -text "OK" \ -command "destroy .topmsg" pack .topmsg.butt \ -side bottom \ -anchor center \ -fill none \ -expand 0 ##################################### ## LOAD MSG INTO TEXT WIDGET. ##################################### ## .topmsg.text delete 1.0 end .topmsg.text insert end $VARtext .topmsg.text configure -state disabled } ## END OF PROC 'popup_msg_var_scroll' ##+######################## ## END of PROC definitions. ##+######################## set HELPtext "\ \ \ \ \ \ ** HELP for the 'tkVisualizer_RadialLines' utility ** This Tk GUI script provides a GUI for implementing a 'Visualizer' --- such as an 'audio visualizer' --- which shows an animation on a Tk GUI 'canvas' widget. This particular 'visualizer' is named 'tkVisualizer_RadialLines' because it draws lines (colored and of various lengths), where the lines emanate radially from a central point on a Tk canvas. This 'RadialLines' visualizer's animation involves the drawing of radial line-segments (emanating from the middle of the canvas) where multiple aspects of each line segment are randomized: - line color - line width - line angle - end-points of each line segment. The visual animation can be driven to change the drawing of each line segment according to a numeric input (a 'driver number') such as - audio input (amplitudes and/or fequencies) - computer CPU usage (overall or from an individual process) - network-interface usage (such as packets transmitted or received) OR - input generated from a random-number generator. The line-segments are created on the canvas using Tk canvas 'create line' commands. The Tcl 'rand' (random) command --- and/or the 'driver number' --- may be employed to generate some randomness in various aspects of the animation, such as - line-segment directions (an angle between 0 and 2*pi radians) - line-segment end-point pairs (and thus the line lengths) - line-segment colors - line-segment widths. The specific calculations used to generate these aspects of the line-segments can be seen in the 'animate' proc of the Tk script. ***************** CANVAS BACKGROUND: ***************** This GUI has a background-color button by which the user can specify the color of the canvas background. Alternatively --- via an entry widget and a browse-for-file option --- the user can read an image file for the canvas background, to cover or partially-cover (or tile) the canvas and its background color. **************** IMAGE BACKGROUND: **************** To put a background image on the canvas, you can use the 'Browse...' button to fetch an image filename into the filename entry field. Either - press the Return/Enter key with the text cursor in the filename entry field (after there is an entry in the field, of course) OR - click MB3 (mouse button 3) on the filename entry field. You can click and release MB3 on the filename in the entry field, to (re)LOAD the image from the image file to the canvas. Eventually, if a small image is chosen, this script may 'tile' the image over a larger canvas area. **************** CAPTURING IMAGES: **************** To capture any single image of the drawing on the canvas, the user can use a screen/window capture utility (such as 'gnome-screenshot' on Linux) to capture the image in an image file format, such as PNG. An image editor (such as 'mtpaint' on Linux) can be used to 'crop' the captured image if necessary --- and can be used to apply processing options such as 'gamma' or 'brightness' correction or whatever. The resulting image file(s) can be printed with an image view-and-print utility (such as 'eog' = 'Eye of Gnome' on Linux). --- A 'WriteAniGIF' or 'WriteMovie' button may (eventually) be provided on the GUI, by which to capture the moving image in an animated-GIF file or movie file. " ##+###################################################### ##+###################################################### ## Additional GUI INITIALIZATION: ## (for APPLICATION-SPECIFIC initialization; i.e. for ## app or widget VARIABLES --- NOT widget PARAMETERS ## like button padding or '-relief' settings.) ##+###################################################### ##+###################################################### ## Set the value of pi to be used in drawing lines. set pi [expr {4.0 * atan(1.0)}] ##+##################################################### ## Set the full-name of the RGB COLOR-selector Tk script ## that may be used in procs above. ##+##################################################### ## FOR TESTING: # puts "argv0: $argv0" set DIRthisScript "[file dirname $argv0]" set DIRupOne "[file dirname "$DIRthisScript"]" set DIRupTwo "[file dirname "$DIRupOne"]" set ColorSelectorScript "$DIRupTwo/SELECTORtools/tkRGBselector/sho_colorvals_via_sliders3rgb.tk" ## Alternatively (or for testing): ## Put the RGB color-selector Tk script in the same directory ## as this Tk script and uncomment the following. # set ColorSelectorScript "$DIRthisScript/sho_colorvals_via_sliders3rgb.tk" ##+##################################################### ## Set an initial directory for the 'Browse...' feature. ## And keep track of last-used directory in $curDIR. ## ## NOTE: You may want to set this to a directory that ## contains suitable background image files. ##+##################################################### # set curDIR "$env(HOME)" ## FOR TESTING: set curDIR "pwd" ##+##################################################### ## Initialize some entry fields that are shown ## on the GUI and set via the GUI. ## ## NOTE: If you have some image background that you ## typically want to use, you can use the name ## of that image file here. ##+##################################################### set ENTRYfilename "" ##+############################################################### ## Initialize the color variables --- for canvas background. ## ## (To avoid overpowering the user's eyes with a white background, ## we start with background=black.) ##+############################################################### # set COLORBKGDr 60 # set COLORBKGDg 60 # set COLORBKGDb 60 set COLORBKGDr 0 set COLORBKGDg 0 set COLORBKGDb 0 set COLORBKGDhex \ [format "#%02X%02X%02X" $COLORBKGDr $COLORBKGDg $COLORBKGDb] set_background_button_color ##+########################################### ## Set the background color of the canvas. ##+########################################### .fRcanvas.can configure -bg $COLORBKGDhex ##+########################################### ## Set the background color of the msg label. ##+########################################### .fRmsg.labelMSG configure -bg "#ff6633" ##+########################################### ## Set a maximum line-width for the ## radial lines that are to be drawn. ## (Could control this by an added widget ## on the GUI.) ##+########################################### set lineMAXWIDTHpx 6 ##+########################################### ## Disable some of the 'driver' radiobuttons, ## until the scripts for them are implemented. ##+########################################### .fRcontrols1.radbuttCPU configure -state disabled .fRcontrols1.radbuttNETWORK configure -state disabled .fRcontrols1.radbuttAUDIO configure -state disabled ##+########################################### ## Display an initial message to the user. ##+########################################### advise_user \ "** Click 'Start' - after, optionally, setting \ background color (or image), the driving data, other options. **" ##+########################################### ## Initialize the speed control. ##+########################################### set WAITmillisecs 10 # set WAITmillisecs 0 ##+########################################### ## Initialize the image area size. ##+########################################### set VARimgsizePx 400 # set VARimgsizePx 500 .fRcanvas.can configure -width $VARimgsizePx -height $VARimgsizePx .fRcanvas.can configure -scrollregion "0 0 $VARimgsizePx $VARimgsizePx"