summaryrefslogtreecommitdiffstats
path: root/library/demos/rolodex
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2001-10-30 10:17:07 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2001-10-30 10:17:07 (GMT)
commit7a22b0cc08ac0cb685315130f93ed8d579b29daa (patch)
treeef05e2b7935510c2f78fd3dcd1878c3390cd9dc6 /library/demos/rolodex
parentae78f51281c62b80a04f7fac74514e77c50d414f (diff)
downloadtk-7a22b0cc08ac0cb685315130f93ed8d579b29daa.zip
tk-7a22b0cc08ac0cb685315130f93ed8d579b29daa.tar.gz
tk-7a22b0cc08ac0cb685315130f93ed8d579b29daa.tar.bz2
More demo upgrades derived from 8.3.4 and using new features
Diffstat (limited to 'library/demos/rolodex')
-rw-r--r--library/demos/rolodex78
1 files changed, 39 insertions, 39 deletions
diff --git a/library/demos/rolodex b/library/demos/rolodex
index 7b22bad..8245a67 100644
--- a/library/demos/rolodex
+++ b/library/demos/rolodex
@@ -1,6 +1,6 @@
#!/bin/sh
# the next line restarts using wish \
-exec wish "$0" "$@"
+exec wish8.4 "$0" ${1+"$@"} || exec wish "$0" ${1+"$@"}
# rolodex --
# This script was written as an entry in Tom LaStrange's rolodex
@@ -8,12 +8,14 @@ exec wish "$0" "$@"
# feel of a rolodex program, although it's lifeless and doesn't
# actually do the rolodex application.
#
-# RCS: @(#) $Id: rolodex,v 1.2 1998/09/14 18:23:29 stanton Exp $
+# RCS: @(#) $Id: rolodex,v 1.3 2001/10/30 10:17:07 dkf Exp $
foreach i [winfo child .] {
catch {destroy $i}
}
+set version 1.2
+
#------------------------------------------
# Phase 0: create the front end.
#------------------------------------------
@@ -23,12 +25,9 @@ pack .frame -side top -fill y -anchor center
set names {{} Name: Address: {} {} {Home Phone:} {Work Phone:} Fax:}
foreach i {1 2 3 4 5 6 7} {
- frame .frame.$i
- pack .frame.$i -side top -pady 2 -anchor e
-
- label .frame.$i.label -text [lindex $names $i] -anchor e
- entry .frame.$i.entry -width 30 -relief sunken
- pack .frame.$i.entry .frame.$i.label -side right
+ label .frame.label$i -text [lindex $names $i] -anchor e
+ entry .frame.entry$i -width 35
+ grid .frame.label$i .frame.entry$i -sticky ew -pady 2 -padx 1
}
frame .buttons
@@ -77,7 +76,7 @@ proc fileAction {} {
proc addAction {} {
global names
foreach i {1 2 3 4 5 6 7} {
- puts stderr [format "%-12s %s" [lindex $names $i] [.frame.$i.entry get]]
+ puts stderr [format "%-12s %s" [lindex $names $i] [.frame.entry$i get]]
}
}
.buttons.add config -command addAction
@@ -88,20 +87,20 @@ proc addAction {} {
proc clearAction {} {
foreach i {1 2 3 4 5 6 7} {
- .frame.$i.entry delete 0 end
+ .frame.entry$i delete 0 end
}
}
.buttons.clear config -command clearAction
proc fillCard {} {
clearAction
- .frame.1.entry insert 0 "John Ousterhout"
- .frame.2.entry insert 0 "CS Division, Department of EECS"
- .frame.3.entry insert 0 "University of California"
- .frame.4.entry insert 0 "Berkeley, CA 94720"
- .frame.5.entry insert 0 "private"
- .frame.6.entry insert 0 "510-642-0865"
- .frame.7.entry insert 0 "510-642-5775"
+ .frame.entry1 insert 0 "John Ousterhout"
+ .frame.entry2 insert 0 "CS Division, Department of EECS"
+ .frame.entry3 insert 0 "University of California"
+ .frame.entry4 insert 0 "Berkeley, CA 94720"
+ .frame.entry5 insert 0 "private"
+ .frame.entry6 insert 0 "510-642-0865"
+ .frame.entry7 insert 0 "510-642-5775"
}
.buttons.search config -command "addAction; fillCard"
@@ -123,7 +122,7 @@ bind . <Control-f> fileAction
.menu.file.m entryconfig 2 -accel Ctrl+Q
bind . <Control-q> {destroy .}
-focus .frame.1.entry
+focus .frame.entry1
#----------------------------------------------------
# Phase 6: help
@@ -145,42 +144,43 @@ proc Help {topic {x 0} {y 0}} {
}
proc getMenuTopic {w x y} {
- return $w.[$w index @[expr $y-[winfo rooty $w]]]
+ return $w.[$w index @[expr {$y-[winfo rooty $w]}]]
}
-bind . <Any-F1> {Help [winfo containing %X %Y] %X %Y}
-bind . <Any-Help> {Help [winfo containing %X %Y] %X %Y}
+event add <<Help>> <F1> <Help>
+bind . <<Help>> {Help [winfo containing %X %Y] %X %Y}
+bind Menu <<Help>> {Help [winfo containing %X %Y] %X %Y}
# Help text and commands follow:
set helpTopics(.menu.file) {This is the "file" menu. It can be used to invoke some overall operations on the rolodex applications, such as loading a file or exiting.}
set helpCmds(.menu.file.m) {getMenuTopic $topic $x $y}
-set helpTopics(.menu.file.m.0) {The "Load" entry in the "File" menu posts a dialog box that you can use to select a rolodex file}
-set helpTopics(.menu.file.m.1) {The "Exit" entry in the "File" menu causes the rolodex application to terminate}
+set helpTopics(.menu.file.m.1) {The "Load" entry in the "File" menu posts a dialog box that you can use to select a rolodex file}
+set helpTopics(.menu.file.m.2) {The "Exit" entry in the "File" menu causes the rolodex application to terminate}
set helpCmds(.menu.file.m.none) {set topic ".menu.file"}
-set helpTopics(.frame.1.entry) {In this field of the rolodex entry you should type the person's name}
-set helpTopics(.frame.2.entry) {In this field of the rolodex entry you should type the first line of the person's address}
-set helpTopics(.frame.3.entry) {In this field of the rolodex entry you should type the second line of the person's address}
-set helpTopics(.frame.4.entry) {In this field of the rolodex entry you should type the third line of the person's address}
-set helpTopics(.frame.5.entry) {In this field of the rolodex entry you should type the person's home phone number, or "private" if the person doesn't want his or her number publicized}
-set helpTopics(.frame.6.entry) {In this field of the rolodex entry you should type the person's work phone number}
-set helpTopics(.frame.7.entry) {In this field of the rolodex entry you should type the phone number for the person's FAX machine}
-
-set helpCmds(.frame.1.label) {set topic .frame.1.entry}
-set helpCmds(.frame.2.label) {set topic .frame.2.entry}
-set helpCmds(.frame.3.label) {set topic .frame.3.entry}
-set helpCmds(.frame.4.label) {set topic .frame.4.entry}
-set helpCmds(.frame.5.label) {set topic .frame.5.entry}
-set helpCmds(.frame.6.label) {set topic .frame.6.entry}
-set helpCmds(.frame.7.label) {set topic .frame.7.entry}
+set helpTopics(.frame.entry1) {In this field of the rolodex entry you should type the person's name}
+set helpTopics(.frame.entry2) {In this field of the rolodex entry you should type the first line of the person's address}
+set helpTopics(.frame.entry3) {In this field of the rolodex entry you should type the second line of the person's address}
+set helpTopics(.frame.entry4) {In this field of the rolodex entry you should type the third line of the person's address}
+set helpTopics(.frame.entry5) {In this field of the rolodex entry you should type the person's home phone number, or "private" if the person doesn't want his or her number publicized}
+set helpTopics(.frame.entry6) {In this field of the rolodex entry you should type the person's work phone number}
+set helpTopics(.frame.entry7) {In this field of the rolodex entry you should type the phone number for the person's FAX machine}
+
+set helpCmds(.frame.label1) {set topic .frame.entry1}
+set helpCmds(.frame.label2) {set topic .frame.entry2}
+set helpCmds(.frame.label3) {set topic .frame.entry3}
+set helpCmds(.frame.label4) {set topic .frame.entry4}
+set helpCmds(.frame.label5) {set topic .frame.entry5}
+set helpCmds(.frame.label6) {set topic .frame.entry6}
+set helpCmds(.frame.label7) {set topic .frame.entry7}
set helpTopics(context) {Unfortunately, this application doesn't support context-sensitive help in the usual way, because when this demo was written Tk didn't have a grab mechanism and this is needed for context-sensitive help. Instead, you can achieve much the same effect by simply moving the mouse over the window you're curious about and pressing the Help or F1 keys. You can do this anytime.}
set helpTopics(help) {This application provides only very crude help. Besides the entries in this menu, you can get help on individual windows by moving the mouse cursor over the window and pressing the Help or F1 keys.}
set helpTopics(window) {This window is a dummy rolodex application created as part of Tom LaStrange's toolkit benchmark. It doesn't really do anything useful except to demonstrate a few features of the Tk toolkit.}
set helpTopics(keys) "The following accelerator keys are defined for this application (in addition to those already available for the entry windows):\n\nCtrl+A:\t\tAdd\nCtrl+C:\t\tClear\nCtrl+D:\t\tDelete\nCtrl+F:\t\tEnter file name\nCtrl+Q:\t\tExit application (quit)\nCtrl+S:\t\tSearch (dummy operation)"
-set helpTopics(version) {This is version 1.0.}
+set helpTopics(version) "This is version $version."
# Entries in "Help" menu