# the next line restarts using wish \
exec wish "$0" "$@"
# widget --
# This script demonstrates the various widgets provided by Tk,
# along with many of the features of the Tk toolkit. This file
# only contains code to generate the main window for the
# application, which invokes individual demonstrations. The
# code for the actual demonstrations is contained in separate
# ".tcl" files is this directory, which are sourced by this script
# as needed.
#
# SCCS: @(#) widget 1.21 96/10/04 17:09:34
#----------------------------------------------------------------
# The code below create the main window, consisting of a menu bar
# and a text widget that explains how to use the program, plus lists
# all of the demos as hypertext items.
#----------------------------------------------------------------
-takefocus 1
# Create a bunch of tags to use in the text widget, such as those for
# section titles and demo descriptions. Also define the bindings for
# tags.
# We put some "space" characters to the left and right of each demo description
# so that the descriptions are highlighted only when the mouse cursor
# is right over them (but not when the cursor is to their left or right)
#
-underline 1
-underline 1
} else {
-foreground blue -underline 1
-foreground #303080 -underline 1
}
}
set lastLine ""
showStatus [.t index {@%x,%y}]
}
.statusBar.lab config -text ""
}
if {$i >= 0} {
}
}
showStatus [.t index {@%x,%y}]
}
# Create the text for the text widget.
.t insert end {
This application provides a front end for several short scripts that demonstrate what you can do with Tk widgets. Each of the numbered lines below describes a demonstration; you can click on it to invoke the demonstration. Once the demonstration window appears, you can click the "See Code" button to see the Tcl/Tk code that created the demonstration. If you wish, you can edit the code and click the "Rerun Demo" button in the code window to reinvoke the demonstration with the modified code.
}
.t insert end "8. A simple user interface for viewing images." \
.t insert end "2. Colors: change the color scheme for the application." \
.t insert end "1. A window containing several menus and cascades." \
focus .s
# positionWindow --
# This procedure is invoked by most of the demos to position a
# new demo window.
#
# Arguments:
# w - The name of the window to position.
}
# showVars --
# Displays the values of one or more variables in a window, and
# updates the display whenever any of the variables changes.
#
# Arguments:
# w - Name of new window to create for display.
# args - Any number of names of variables.
toplevel $w
set len 1
foreach i $args {
}
}
foreach i $args {
frame $w.$i
}
}
# invoke --
# This procedure is called when the user clicks on a demo description.
# It is responsible for invoking the demonstration.
#
# Arguments:
# index - The index of the character that the user clicked on.
if {$i < 0} {
return
}
}
# showStatus --
#
# Show the name of the demo program in the status bar. This procedure
# is called when the user moves the cursor over a demo description.
#
if {$i < 0} {
.statusBar.lab config -text " "
} else {
.statusBar.lab config -text "Run the \"$demo\" sample program"
}
if [string compare $cursor $newcursor] {
.t config -cursor $newcursor
}
}
# showCode --
# This procedure creates a toplevel window that displays the code for
# a demonstration and allows it to be edited and reinvoked.
#
# Arguments:
# w - The name of the demonstration's window, which can be
# used to derive the name of the file containing its code.
pack .code.buttons -side bottom -fill x
button .code.buttons.dismiss -text Dismiss -command "destroy .code"
eval [.code.text get 1.0 end]
}
text .code.text -height 40 -wrap word\
-setgrid 1 -highlightthickness 0 -pady 2 -padx 3
grid .code.text -in .code.frame -padx 1 -pady 1 \
grid .code.yscroll -in .code.frame -padx 1 -pady 1 \
# grid .code.xscroll -in .code.frame -padx 1 -pady 1 \
# -row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news
grid rowconfig .code.frame 0 -weight 1 -minsize 0
grid columnconfig .code.frame 0 -weight 1 -minsize 0
} else {
}
wm title .code "Demo code: [file join $tk_library demos $file]"
.code.text delete 1.0 end
.code.text insert 1.0 [read $id]
.code.text mark set insert 1.0
}
# aboutBox --
#
# Pops up a message box with an "about" message
#
"Tk widget demonstration\n\n\
Copyright (c) 1996 Sun Microsystems, Inc."
}