FE 'tkGooie' Utilities

'TkGUIs EMBELLISHED demos'
group

Scripts to
MAKE EMBELLISHED TOOLCHESTS

(menu-making
demo scripts)

(FE = Freedom Environment)

A 'demo' toolchest made with
one background image on a
Tk canvas --- with 'drawers'
marked with separator lines.

FE Home Page > FE Downloads Page >

FE 'tkGooies' Description Page >

FE 'tkGooies' 'TkGUIs EMBELLISHED demos' Menu Page >

This
'MAKE EMBELLISHED TOOLCHESTS'
tkGooie demo Page

INTRODUCTION to
'Make Embellished Toolchests' Tk demo scripts

Before retiring in 2005, I had the good fortune to work for about 8 years on SGI/IRIX (Unix) workstations.

On those workstation 'desktop' screens, there was the concept of 'toolchests' by which one could startup applications.

The toolchests served the same function as the 'Start' menus on PC's.

The main difference in implementation on the SGI desktop is that the main toolchest started at the top-left of the screen instead of the bottom left --- and they had a different look --- an X-Motif look.

After I retired, I thought I would like to make toolchests of apps and utilities on my Linux PC's.

On the SGI's, to add toolchests, one had to make text files of a certain format --- to define the 'drawers' of the toolchest, as well as separator lines and label (group heading) lines, where needed.

There was an underlying, compiled toolchest-making program on the SGI's that would make the toolchests from those text files --- both SGI-supplied toolchests and user-added toolchests.

Unfortunately, there was no such toolchest making program on my PC's --- at least not a program that I could get into and make work how I wanted it to work.

In fact, I had a bad experience with application menus, back around 2005, when using Mandriva Linux with a KDE desktop.

I used the KDE menu editor to make some additions to the app menus, but there was a bug in the KDE menu system.

Some of my additions would not show.

And when I tried to add them again, I got a message saying they were already there.

I was caught between a rock and a hard place.

I decided then and there that I was going to make my own toolchest making system --- using Tcl-Tk to make the toolchests.

I devised a simple format for the text files that would define the toolchests.

I just had to make a Tcl-Tk script that would read the lines of the 'chest definition' files and make toolchests.

I wasn't sure that it was possible to make a Tk script that would read such a text file and generate a 'toolchest' GUI within a fraction of a second.

Let me just say that I was pleasantly surprised.

I decided to make the toolchest 'drawers' with 'button' widgets.

I managed to crank out a 'make_chest.tk' script that had several sections within a read-loop in the script --- sections for making

  • 'active' drawers

  • inactive (grayed out) drawers

  • label (group-heading) drawers

  • separator lines (made with thin 'frame' widgets).

My Tk-button toolchests ended up looking something like this.

You can see screenshots (and descriptions) of the more feature-rich toolchests of my 'Freedom Environment' (FE) software in the 'feAppMenus' and 'feHandyTools' sections of an FE screenshots gallery page.

    (The FE 'feHandyTools' system is 'deprecated' and is being replaced by the FE 'tkGooies' system.)

With the FE toolchests, the user has the ability to change the color scheme in the toolchests via a Tk color selector GUI.

You can make that color-selector script by downloading the code from the page offering 'a non-obfuscated color selector GUI', on this site.

The color scheme of the toolchests is changed via the 'tk_setPalette' command.

In the FE toolchests, the user can also change (or eliminate) the 'bullet' images used on the left of each drawer.

This is all nice --- but not nice enough.

I am hoping to make more attractive toolchests --- ones that even Steve Jobs would have envied --- by making variations on my Tk-button 'make_chest.tk' script.

I was hoping to use the '-compound' parameter of the 'button' command to provide images BEHIND the text on the drawers --- not just the 'bullet' images to the LEFT of the text.

But I hit a problem with the '-compound' parameter that is documented in a 'text on image' wish that I posted on the page titled 'Tk 9.0 Wishlist' at wiki.tcl.tk.

Since that wish may not be implemented in my lifetime (and perhaps never), I have been experimenting with using the 'canvas' widget to make 'embellished' toolchests.


Three types of toolchests (screenshots)

Below are three images corresponding to three basically different techniques that I have tried so far.

A description of the basics of each toolchest implementation is under each image.

TOOLCHEST DRAWERS ARE MADE WITH:
'canvas' widgets

DRAWER ACTIONS ARE PROVIDED BY:
button1-release bindings on the canvas widgets

TOOLCHEST/DRAWER DECORATION IS PROVIDED BY:
'create line' commands on the canvas widgets --- to provide COLOR GRADIENT BACKGROUNDS for the 'drawers'.

    Uses a 'DrawGradient' proc based on Tcl-Tk scripts by B. Oakley and Damon Courtney and published on a page titled 'Drawing Gradients on a Canvas' on wiki.tcl.tk.

TOOLCHEST DRAWERS ARE MADE WITH:
'canvas' widgets (one for each drawer)

DRAWER ACTIONS ARE PROVIDED BY:
button1-release bindings on the canvas widgets

TOOLCHEST/DRAWER DECORATION IS PROVIDED BY:
'image create' for a background image on the canvas widgets.

A rectangular GIF image file is read to make an in-memory image structure with 'image create photo'.

That image structure is used in Tk canvas 'image create' statements to put the background on the drawers.

At first, I used an 'eval' technique to load the text strings (for the drawers) into variables such as TXTstring1, TXTstring2, ...

Similarly, at first, I used 'eval' to make canvas IDs such as .can1, .can2, ...

To avoid a lot of 'escaping' of special characters (double-quotes, braces, brackets), I ended up loading the text strings for the drawers into an array variable.

In addition to putting the text strings into an array variable, I ended up defining the canvas widgets as .can(1), .can(2), ... rather than .can1, .can2, ...

In a loop over the array argument (drawer count), the canvases are defined-and-packed (with image and text put on each canvas).

Also in the loop, the bindings to button1-release are defined --- with Tk 'bind' statements.

TOOLCHEST DRAWERS ARE MADE WITH:
text lines, each with a tag for a binding

DRAWER ACTIONS ARE PROVIDED BY:
button1-release bindings on the text tags

TOOLCHEST/DRAWER DECORATION IS PROVIDED BY:
'image create' for a background image on the one big canvas widget.

A rectangular GIF image file is read to make an in-memory image structure with 'image create photo'.

That image structure is used in a Tk canvas 'image create' statement to put the background on the ONE canvas widget of this GUI.


And below is a description of the basics of the Tk-button toolchest --- the first image above --- shown again here:

TOOLCHEST DRAWERS ARE MADE WITH:
'button' widgets

DRAWER ACTIONS ARE PROVIDED BY:
the '-command' parm of 'button'

TOOLCHEST/DRAWER DECORATION IS PROVIDED BY:
the 'tk_setPalette' command, with an optional 'bullet' image on the left of each button/drawer, applied with the '-compound left' parameter of the button widget.


Code for the 4 toolchests

Since I want to 'give back' to the Tcl-Tk community --- and help out any 'newbies' out there trying to get up to speed in Tcl-Tk programming, here is the code corresponding to the 4 toolchest images above.


CODE FOR THE BUTTONS/COLOR-PALETTE/BULLETS toolchest:

Here is a link to CODE for the Tk script
'make_chest_proto_buttonsInFrames.tk'.

This is the technique I used for the original 'make_chest.tk' script used in the 'feAppMenus', 'feHandyTools', and 'tkGooies' FE systems.


CODE FOR THE COLOR-GRADIENT-DRAWERS toolchest:

Here is a link to CODE for the Tk script
'make_chest_proto_gradientLinesInCanvases.tk'.

    (Each drawer is drawn by a 'DrawGradient' proc --- hence this is not the most efficient method.

    It is probably better to capture a color gradient in an image file and use the image file with the following two techniques.

    And hence my code donation on a page offering a 'A color-gradient-button-maker GUI'.


CODE FOR THE ONE-IMAGE-PER-DRAWER toolchest:

Here is a link to CODE for the Tk script
'make_chest_proto_imageCreateInCanvases_txt-can-arrays.tk'.


CODE FOR THE ONE-IMAGE-PER-ENTIRE-TOOLCHEST toolchest:

Here is a link to CODE for the Tk script
'make_chest_proto_imageOnOneCanvas_textLineTagBindings.tk'.


In the Tk scripts above, I use a Tk coding structure that is discussed in more detail on the page A Canonical Structure for Tk Code --- and variations.


CONCLUSION

Now I have plenty to do in the coming years.

I plan to integrate a couple of these toolchest making techniques into the 'tkGooies' and 'feAppMenus' subsystems of my Freedom Environment software on this site.

Below is an image that shows that the backgrounds of the drawers do not have to be just vertical or horizontal color gradients.

The background for these drawers was cropped from a color relief map of east Texas.

However, this image also shows that it may not be so easy to find pleasing backgrounds for the drawers.

So far, I have found that simple color gradients provide the most pleasing backgrounds.

Bottom of this page for
Making Embellished Toolchests (menus)
--- presenting several Tk demo scripts
--- for making 'embellished toolchests'
--- demos in the FE 'tkGooies' system,
in the 'TkGUIs EMBELLISHED demos' group.

To return to a previously visited web page location, click on the Back button of your web browser a sufficient number of times. OR, use the History-list option of your web browser.
OR ...

< Go to Top of Page, above. >

Page history:

The code was created in 2012 --- and posted 2012 Aug 13 at http://wiki.tcl.tk/36780.

This FE web page was created 2014 May 14.
(as a backup and alternative to the wiki.tcl.tk page)

This page was changed 2015 Oct 05.
(Small changes.)

Page was changed 2019 Feb 27.
(Added css and javascript to try to handle text-size for smartphones, esp. in portrait orientation.)

Page was changed 2019 Jun 18.
(Specified image widths in percents to size the images according to width of the browser window.)


NOTE:
The demo code here MAY BECOME more 'up-to-date' than the code originally posted on the Tcler's Wiki ---
wiki.tcl-lang.org --- formerly wiki.tcl.tk.