File: runExtendedDemos.tcl

package info (click to toggle)
plplot 5.15.0%2Bdfsg-19
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 31,312 kB
  • sloc: ansic: 79,707; xml: 28,583; cpp: 20,033; ada: 19,456; tcl: 12,081; f90: 11,431; ml: 7,276; java: 6,863; python: 6,792; sh: 3,274; perl: 828; lisp: 75; makefile: 50; sed: 34; fortran: 5
file content (83 lines) | stat: -rw-r--r-- 2,033 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#----------------------------------------------------------------------------
# Source this file into a working Tk interpreter to run all the Tcl demos
# in a nice window with buttons for each demo you'd like to run.
#
# This requires the 'Plplotwin' extended widget.  If you don't have that
# widget set up (from the 'tk-x-plat' bindings), then use the
# 'runAllDemos.tcl' script instead.
#
# Vince Darley
# vince@santafe.edu
#
#----------------------------------------------------------------------------

if {[catch {file readlink [info script]} path]} {
    set path [info script]
}
cd [file join [file dirname $path] .. tcl]
lappend auto_path "[pwd]"
catch {package require Plplotter}
Plplotwin .p
grid .p -columnspan 5 -sticky news
grid rowconfigure . 0 -weight 1
for {set i 0} {$i < 5} {incr i} {
    grid columnconfigure . $i -weight 1
}

# turn on pauses
.p cmd plspause 1

button .cexit -text "Quit" -command exit
button .cshell -text "Shell" -command "console show"
button .creload -text "Reload" -command reload
button .ctoggle -text "Toggle Menu" -command toggleMenu

set buttons [list .cexit .cshell .creload .ctoggle]

proc toggleMenu {} {
    if {[.p cget -menulocation] == "menubar"} {
	.p configure -menulocation local
    } else {
	.p configure -menulocation menubar
    }
}

proc reload {} {
    global demos
    foreach demo $demos {
	catch {rename $demo {}}
    }
    auto_reset
}

proc run {demo} {
    setButtonState disabled
    .p bop
    update idletasks
    if {[catch {$demo .p} err]} {
	puts stderr $err
    }
    .p bop
    setButtonState normal
}

proc setButtonState {state} {
    foreach b [info commands .b*] {
	$b configure -state $state
    }
}

for {set i 1} {$i <= [llength [glob x*.tcl]]} {incr i} {
    set demo x[format "%02d" $i]
    button .b$i -text "Demo $i" -command [list run $demo]
    lappend demos $demo
    lappend buttons .b$i
    if {[llength $buttons] == 5} {
	eval grid $buttons -sticky ew
	set buttons {}
    }
}

if {[llength $buttons]} {
    eval grid $buttons -sticky ew
}