Make your own free website on Tripod.com

Examples for
Graphical Applications with Tcl and Tk
Second Edition
by Eric Foster-Johnson

Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Chapter 14
Chapter 15
Chapter 16

Note: If you have installed the Tcl plug in, then you probably want to turn it off before calling up one of the examples.


Chapter 1

FileContains
exectest.tcl Test of #!/bin/sh syntax.
hello.tcl /usr/local/bin/wish8.0
newtext.tcl Tcl script with different text in a button.

Chapter 2

FileContains
add.tcl Defining procedures within procedures.
arrayset.tcl Tcl array set example.
arsearch.tcl Tcl array search example.
break1.tcl Example of break.
break2.tcl Breaks out of innermost loop, not outermost.
cont.tcl Example of continue.
estimate.tcl Procedure to estimate software projects.
for1.tcl Looping with the for command
foreach1.tcl Example of foreach.
foreach2.tcl foreach with array names
format1.tcl Example of format.
format2.tcl format with decimal values.
format3.tcl format with hexadecimal and octal values.
global.tcl Use of global in procedures.
makeb.tcl Simple procedure to create a button.
mintol.tcl Use of default arguments for procedures.
myparray.tcl A simple version of parray.
onearg.tcl One required argument plus args.
printarg.tcl Variable number of arguments.
regexp1.tcl HTML regexp example.
regexp2.tcl Example with regexp storing results.
regexp3.tcl Example of regexp and sub expressions.
regsub1.tcl Example of regsub
scan.tcl The scan command.
stroke.tcl Defining a procedure.
switch1.tcl Example of switch -regexp
switch2.tcl switch -regexp
upvar.tcl Use of upvar.

Chapter 3

FileContains
b1.tcl .b1 widget example from Chapter 3.
b1_b2.tcl .b1 and .b2 widget examples from Chapter 3.
b2.tcl .b2 widget example from Chapter 3.
b3.tcl .b3 widget example from Chapter 3.
b4.tcl Font creation test.
b5.tcl Another Font creation test.
b8.tcl Example of specifiying a font
b9.tcl Example of specifying a font
b_cmd1.tcl Exploring the -command option for buttons.
b_cmd2.tcl Exploring the -command option for buttons.
b_cmd3.tcl Exploring the -command option for buttons.
cget.tcl Using cget.
check1.tcl checkbutton.
check2.tcl checkbutton with on and off values.
config1.tcl Using configure.
fontact.tcl Examples of font actual.
fontconf.tcl Changing a font using font configure.
fontdel.tcl Test for deleting a font.
fontfam.tcl Lists available font families using Tk 8.0 font command.
fontmeas.tcl Measuring the number of pixels wide in a given font.
fontmet.tcl Example of font metrics.
fontopts.tcl Examples of font options.
frame1.tcl Use of the frame widget.
frame2.tcl Multiple frames with pack.
frame3.tcl Multiple frames with grid.
grid1.tcl Test of grid command for placing widgets.
grid2.tcl Test of grid command for placing widgets.
gridrel.tcl Test of relative grid placement
label.tcl The label widget.
message.tcl message widget.
pack1.tcl pack -side left
pack2.tcl pack -side right
pack3.tcl pack -side top
pack4.tcl pack -side top inserting a widget.
pack5.tcl pack -side top inserting a widget.
packfill.tcl pack example using -fill x.
place.tcl Example with place geometry layout.
radio.tcl radiobutton example.
relief.tcl Use of the -relief option.
rgbscale.tcl RGB color-setting scale.
scale1.tcl Simple scale widget.
scale2.tcl scale widget with -from and -to.
scale3.tcl scale widget with a -label.
scale4.tcl scale widget with -command Tcl code.
scale5.tcl scale widget with -command Tcl code
scale6.tcl scale widget with -length.
textvar.tcl Using the -textvariable widget option.
textvar2.tcl Using the -textvariable widget option.
winfont.tcl Using Windows system-specific fonts.
winxlfd.tcl Using X Window XLFD font naming on Windows.

Chapter 4

FileContains
bind1.tcl Button-3 binding.
bind2.tcl Use of %x %y in bind
bind3.tcl Prints Tcl name for each key pressed in window.
bind4.tcl Binding keyboard accelerators.
cascade.tcl Cascaded submenus.
editmenu.tcl Example Edit menu.
filemenu.tcl Example File menu.
framebar.tcl Old way to create a menubar.
mainw1.tcl Example main window.
menu.tcl Utility to create menus.
menu1.tcl Using menus and menu bars.
menu2.tcl Using menus and menu bars.
menubar.tcl Procedure used to create a menu bar using
the new and old methods.
option1.tcl Option menu.
popup.tcl Pop-up menu.
status1.tcl A simple status area.
status2.tcl A more complicated status area.
viewmenu.tcl Menu using radio and check buttons.

Chapter 5

FileContains
dataform.tcl Data-entry form using grid command.
embed1.tcl Embedded window inside text widget.
embed2.tcl Embedded window inside text widget.
embed3.tcl Embedded image inside text widget.
entry1.tcl Entry widget example.
entry2.tcl Entry widget example.
interp.tcl Use of interp to create a new Tcl interpreter.
interptk.tcl Loading Tk inside another interpreter.
password.tcl Password entry aligned with label.
scroll.tcl Horizontal and vertical scrollbars.
tag.tcl Text widget tags.
text1.tcl Very simple text editor in Tcl.
text2.tcl Test of text widget indices.
textedit.tcl Tcl-based text editor.
textfind.tcl Example of searching in a text widget.
word.tcl Tcl 8.0 word-searching commands.

Chapter 6

FileContains
dirview.tcl Tcl/Tk Directory Viewer
glob1.tcl Use of glob to list files in a directory.
glob2.tcl Use of glob to list files in a directory.
histlist.tcl Command history listbox example.
minnlist.tcl listbox example.
multlist.tcl Tcl script that creates multiple listboxes.
pr_argv.tcl Tcl script prints out number of command-line arguments.
scrlist.tcl Scrolled listbox example.

Chapter 7

FileContains
colordlg.tcl Tk color dialog.
dialog1.tcl Tk dialog with window manager hints.
dlgerr.tcl Error dialog.
dlginfo.tcl Info dialog.
dlgwarn.tcl Warning dialog.
droplist.tcl Drop-down list code.
filedlg.tcl Tk file dialog.
finddlg.tcl Find dialog for searching a text widget.
fontdlg.tcl Creates a font dialog to select a font.
olddlg.tcl Old-style tk_dialog dialogs.
savedlg.tcl Tk save as dialog.
top1.tcl toplevel widget.
wmclose.tcl Handles window manager Close choice.

Chapter 8

FileContains
base64.tcl Example of base64 encoding for a GIF image.
bitmap1.tcl Displays Tcl's built-in bitmaps.
bitmap2.tcl Create a bitmap using inline data.
bitmap3.tcl Create bitmap.
canarc.tcl Arc items in a canvas.
canbind.tcl Binding items in a canvas.
canbit.tcl Bitmap items in a canvas.
canline.tcl Line items in a canvas.
canoval.tcl Oval items drawn in a canvas.
canpoly.tcl Polygon items drawn in a canvas.
canrect.tcl Rectangle items drawn in a canvas.
canscrl.tcl Scrolling canvas.
cantag.tcl itemconfigure in a canvas.
cantext.tcl Text items drawn in a canvas.
canwind.tcl Embedded window items drawn in a canvas.
image1.tcl Creating a photo image from a GIF file.
image2.tcl Creating a photo image from a PPM file.
picdir.tcl Graphical directory viewer.
toolbar.tcl Example toolbar.

Chapter 9

FileContains
debugtxt.tcl Text widget to display debugging output.
stack.tcl Utility to print calling stack for Tcl interpreter.
tkerror.tcl Overriding tkerror procedure.
trace.tcl Tracing changes to a variable.

Chapter 10

FileContains
after.tcl Use of after for a working... message
cmdexec.tcl Procedure to launch commands.
readpipe.tcl Opening a pipe for reading.

Chapter 11

FileContains
helpdlg.tcl Use of the html_library for online help.
helpexec.tcl Example of online help
helpexp.htm Test HTML file.
helpform.htm Test HTML file.
helpie.tcl Example of Internet Explorer online help
helpnets.tcl Example of Netscape online help
helpnew.htm Test HTML file.
helpopen.htm Test HTML file.
helptest.htm Test HTML file.
html_library.tcl Simple HTML display library by Stephen Uhler (stephen.uhler@sun.com)
httpget.tcl Get URL data with http_get
tooltip.tcl Tooltips help.

Chapter 12

FileContains
client1.tcl Simple client socket example.
client2.tcl Code for a remote client that sends commands to server.
server1.tcl Example of server sockets.
server2.tcl Remote Tcl command server.

Chapter 13

FileContains
tclet1.htm HTML page for tclet1.tcl
tclet1.tcl Tcl applet (tclet) for embedding in a Web page.
tclet2.htm HTML page for tclet2.tcl
tclet2.tcl Tclet example for a data-entry form.
tclform1.cgi CGI Script.
tclform1.htm HTML form for tclform1.cgi.
tclform2.cgi CGI Script.
tclform2.htm HTML form for tclform2.cgi.

Chapter 14

FileContains
allcurs.tcl Shows all cursors
clock.tcl Using clock to get the time.
french.tcl Example File menu in German.
german.tcl Example File menu in German.
iconbit.tcl Icon bitmap
name.tcl Use of name spaces.
registry.tcl Accessing the Windows registry.
restart.tcl Sets up WM_COMMAND for applications
rngbrod6.xbm Ring of Brodgar X Bitmap file.
spanish.tcl Example File menu in German.
splash.tcl Splash screen introduction dialog.
userpref.tcl Loading and saving user preferences.

Chapter 15

FileContains
makefile.unx Sample makefile for UNIX and Linux.
makefile.vc Makefile for MS Visual C++
simple.tcl Test of our simple Tcl interpreter.
tclapp.c Tcl interpreter using Tcl_AppInit.
tclint.c A simple Tcl interpreter.
tkapp.c Tcl interpreter with Tk, using Tcl_AppInit.

Chapter 16

FileContains
linkvar.c Tcl_LinkVar: global variables linked to Tcl variables.
linkvar.tcl Tcl example for linkvar.c
objtest.cxx Test program using Tcl to create C++ objects.
objtest.tcl Test script for C++ testing.
revcmd.c Tcl sample command to reverse two arguments.
revobj.c Tcl sample command with object-based approach.