Tcl-Tk CODE
'SNIPPETS' SOURCES

especially for
WIDGET DEFINITIONS
(and widget packing)

Snippets from scripts
in the FE 'tkGooies' system
--- and from other sources.

(Snippets to facilitate
development of Tk GUI's.)
(FE = Freedom Environment)

This animated-GIF was created
using the 'wheeeMorph' script
of the FE 'tkGooies' system.

FE Home page > FE Downloads page >

FE 'tkGooies' Download page >

'tkGooies' Description page >

'Tcl-Tk Code Snippets Sources' page >

This 'Tcl-Tk WIDGET Definition Sources' page

! Note !
More links to sources of Tcl-Tk code for
WIDGET DEFINITIONS may be added to this page
--- as more and more scripts are added
to the FE 'tkGooies' subsystem.

< Go to Table of Contents, below >
(SKIP THIS INTRO)

INTRODUCTION to sources of
WIDGET code snippets:

As I develop more and more Tk GUI scripts in the FE 'tkGooies' subsystem --- in the group of FE (Freedom Environment) subsystems, I find it extremely helpful to copy 'snippets' of widget-definition-and-packing code from an 'old' tkGooie script, for use in a new 'tkGooie'.

Then, typically, I make some changes to widget names and variable names.

As I publish a script of the 'tkGooies' system in the CODE pages that are available via the 'tkGooies' Description page, I hope that that particular 'tkGooie' script may help others to learn to make Tcl-Tk scripts that are of interest to them.

In the course of these activities ('tkGooie' code development and 'tkGooie' code publishing), I realized that it will be of help to me --- and to other potential Tcler's --- to have a web page that points to sources of various kinds of Tcl-Tk code 'snippets'.

I quickly realized that, when I am looking for a Tcl-Tk code snippet, I am usually looking for a snippet that is of one of 3 general kinds:

  • a WIDGET -
    an example of DEFINITION (and packing) of a widget

  • a BINDING -
    an example of an EVENT binding on a widget

  • a PROC -
    an example to perform a SPECIFIC FUNCTION, such as file-reading, or file-writing, or plotting lines/ovals/polygons on a canvas, or plotting pixels in a photo-image on a canvas, or performing a certain kind of calculation, or whatever.

It is the purpose of this page to provide examples of WIDGET DEFINITIONS --- via links to web pages that present Tcl-Tk code.

---

Most of the links (below) will be to the 'CODE pages' of my 'tkGooies' system --- pages of this FE (Freedom Environment) web site, www.freedomenv.com.

But some links may be 'external' links --- to helpful pages at the Tcler's wiki --- wiki.tcl.tk --- or elsewhere on the web.


Organization of the links below :

There is a standardized Tk coding structure that I use in the development of 'tkGooie' scripts.

I describe that coding structure on the page A Canonical Structure for Tk Code --- and variations.

In that coding structure, I basically organize the code to include 3 main sections:

  • widget definitions
    (the layout of the GUI) --- typically involving defining 'frame' widgets, and then widgets within those frames --- widgets like 'button' widgets, 'label' widgets, 'entry' widgets, etc.

  • 'bind' statements,
    if any are needed in addition to the default bindings that are provided with the Tk widgets.

    The 'bind' statements specify code to be executed when certain 'events' occur, such as moving a mouse on a Tk 'canvas' widget.

  • procs (procedures)
    which may involve various kinds of algorithms to perform calculations, to draw images, to read files, to write files, to execute external programs, etc.

In providing the links below, I provide links for the first of these three --- WIDGET-DEFINITIONS.

A 'Table of Contents' section below can be used to take you to a section of the page below --- where each section corresponds to a widget --- 'frame', 'button', 'label', etc.

Enough of this introduction. Here is the Table of Contents.

The table of contents below provides links to sections of THIS web page that contain links to take the reader to locally-stored or remotely-stored code --- code that contains snippets that may help in making more Tk GUI's.

Table of Contents:

(links to sections of this page, below)

(in alphabetical order by widget-name)

End of Table of Contents.

Start of Sections of Links to Widget-Definition Snippets.

Some Sources of snippets for
'button' widget definitions:

  • Essentially every 'tkGooie' script uses 'button' widgets. See any of the scripts in the other widget groups.

< Go to Table of Contents, above. >

< Go to Top of this page. >

Some Sources of snippets for
'canvas' widget definitions:

  • There are many, many 'tkGooie' scripts that define 'canvas' widgets. Here are a few.

  • tkAngleConvertSelect includes a 'canvas' widget, without scrollbars.

  • tkDegreesMinSecConvertSelect contains a 'canvas' widget with no scrollbars --- and 4 horizontal 'scale' widgets.

  • tkSimulateSinglePendulumNoFriction contains 1 'canvas' widget with no scrollbars --- and 7 'entry' widgets.

  • tkSimulateBouncingBall contains 1 'canvas' widget with no scrollbars --- and 9 'entry' widgets (one of them disabled).

  • wheeeMorph contains 2 'canvas' widgets with scrollbars --- 2 'checkbutton' widgets --- 3 'radiobutton' widgets --- 1 'scale' widget --- 2 'entry' widgets with +/- buttons on each side.

  • rotate_image_on2ndCanvas contains 2 'canvas' widgets with scrollbars --- 1 'scale' widget.

  • imageMagnets contains 1 'canvas' widget with scrollbars --- 2 'scale' widgets --- 1 'entry' widgets with a 'Browse...' button to fetch an image filename.

  • thalesTheorem_rightTriangles_inSemiCircle contains 1 'canvas' widget without scrollbars --- 1 'checkbutton' widget --- 1 'scale' widget.

  • tkCircleCircumferenceByPolygons contains 1 'canvas' widget with scrollbars --- 2 'checkbutton' widgets --- 3 'scale' widgets.

< Go to Table of Contents, above. >

< Go to Top of this page. >

Some Sources of snippets for
'checkbutton' widget definitions:

< Go to Table of Contents, above. >

< Go to Top of this page. >

Some Sources of snippets for
'entry' widget definitions:

  • There are many, many 'tkGooie' scripts that define 'entry' widgets. Here are a few.

  • tkGnuplotXY_upto3mathExpressions
    a 'frontend' for the 'gnuplot' command, to plot up to 3 'curves' from up to 3 math expressions --- provides at least 3 'entry' widgets, for the math expressions.

  • rotate_image_on2ndCanvas
    provides procedures to read an image file, put the image on a canvas, and rotate the image on a 2nd canvas --- provides at least 1 'entry' widget, for a filename.

  • tkSimulateSinglePendulumNoFriction contains 7 'entry' widgets --- and 1 'canvas' widget with no scrollbars.

  • tkSimulateBouncingBall contains 9 'entry' widgets (one of them disabled) --- and 1 'canvas' widget with no scrollbars.

  • wheeeMorph contains 2 'entry' widgets with +/- buttons on each side -- 2 'canvas' widgets with scrollbars --- 2 'checkbutton' widgets --- 3 'radiobutton' widgets --- 1 'scale' widget.

< Go to Table of Contents, above. >

< Go to Top of this page. >

Some Sources of snippets for
'frame' widget definitions:

  • Essentially every 'tkGooie' script uses 'frame' widgets. See any of the scripts in the other widget groups.

< Go to Table of Contents, above. >

< Go to Top of this page. >

Some Sources of snippets for
'label' widget definitions:

  • Essentially every 'tkGooie' script uses 'label' widgets. See any of the scripts in the other widget groups.

< Go to Table of Contents, above. >

< Go to Top of this page. >

Some Sources of snippets for
'listbox' widget definitions:

< Go to Table of Contents, above. >

< Go to Top of this page. >

Some Sources of snippets for
'minilistbox' widget definitions:

  • draw_SUPER-ELLIPSE_colorFilled provides a 'minilistbox' that uses
    two 'button' widgets beside a tiny 'listbox' widget, instead of scrollbars,
    to move the tiny listbox contents up and down.

  • draw_POLYGONSwithROUNDEDcorners_2colors provides TWO 'minilistbox' widgets
    that use 2 'button' widgets beside each tiny listbox.

  • GetComics_viaHTTP provides a similiar widget --- but made with a tiny 'entry'
    widget and 2 'button' widgets, instead of a tiny 'listbox' and 2 'button' widgets.

< Go to Table of Contents, above. >

< Go to Top of this page. >

Some Sources of snippets for
'radiobutton' widget definitions:

  • wheeeDiagram
    provides procedures to put ovals, rectangles, diamonds, lines, text and images on a canvas, located by movements of the mouse cursor on a canvas --- 10 'radiobutton' widgets are used to specify the type of operations to perform on the canvas.

  • FontSelector_fromFreedomEnv
    provides 2 'radiobutton' widgets --- 4 'checkbutton' widgets --- also a 'listbox' widget with scrollbars --- and a 'text' widget with scrollbars.

  • draw2colorXorYgradient_RECTANGLE-BUTTON_colorShaded3D
    includes 2 'radiobutton' widgets --- and 1 'checkbutton' widget.

  • wheeeMorph
    contains 3 'radiobutton' widgets --- 2 'canvas' widgets with scrollbars --- 2 'checkbutton' widgets --- 1 'scale' widget --- 2 'entry' widgets with +/- buttons on each side.

  • wheeeDiagram
    contains 2 groups of 'radiobutton' widgets --- 1 'checkbutton' widget --- 1 'scale' widget.

< Go to Table of Contents, above. >

< Go to Top of this page. >

Some Sources of snippets for
'scale' widget definitions:

< Go to Table of Contents, above. >

< Go to Top of this page. >

Some Sources of snippets for
'miniscale' widget definitions:
(a multi-speed 'spinbox'-like widget)

  • make_colorGradientRECTANGLE_6miniscales
    uses SIX 'miniscale' widgets on this GUI --- to save space --- instead of using six 'scale' widgets.

    (Each 'miniscale' widget is made with one 'label' and two 'button' widgets.)

< Go to Table of Contents, above. >

< Go to Top of this page. >

Some Sources of snippets for
'scrollbar' widget definitions:

  • See examples in the 'canvas', 'listbox', and 'text' sections.

< Go to Table of Contents, above. >

< Go to Top of this page. >

Some Sources of snippets for
'spinbox' widget definitions:

< Go to Table of Contents, above. >

< Go to Top of this page. >

Some Sources of snippets for
'text' widget definitions:

< Go to Table of Contents, above. >

< Go to Top of this page. >



Another animated-GIF that was
created using the 'wheeeMorph' script
of the FE 'tkGooies' system.

Bottom of this page of
Tcl-Tk Code 'Snippets' Sources -
for WIDGET DEFINITIONS

--- a page of links to Tcl-Tk source code
--- mostly links to CODE pages
of the FE 'tkGooies' system.

To return to a previously visited web page, 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 Table of Contents, above. >

< Go to Top of Page, above. >

Page history:

Page was created 2016 Nov 04.

Page was created 2016 Nov 12.
(Added a 'minilistbox' widget section and a 'miniscale' widget section.)

Page was changed 2018 Aug 19.
(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.)