transl: do not assume a catch's mode based on the last body form
[maxima.git] / archive / books / tk_gnuplot
blobbf84c424ec23808f642aa2cbc64d7835e6d651aa
1 #!/bin/sh
2 # comment \
3 exec wish "$0" "$@"
5 set gnuPlotstream [open {| gnuplot } r+]
7 proc sendgnu com {
8 global gnuPlotstream
9 puts stdout $com ; flush stdout
10 puts $gnuPlotstream $com ; flush $gnuPlotstream
13 while {[gets stdin line] >= 0} {
14 sendgnu $line
17 set xrot 60
18 set zrot 30
20 text .text
21 .text configure -height 4 -width 40
23 proc getoptions {} {
24 # unlink gnu-optionsxx
25 set tmp gnu-optionsxx
26 exec rm -f $tmp
27 sendgnu "save '$tmp'\n"
28 while {[file exists $tmp] <= 0} {exec sleep 0}
29 set at [.fra.options nearest 0]
30 set f [ open gnu-optionsxx ]
31 .fra.options delete 0 end
32 while { [gets $f line] > 0 } {
33 .fra.options insert end "$line"
35 .fra.options yview $at
38 frame .fra -bd 2
39 label .fra.label -text "Current Set Options"
40 scrollbar .fra.scroll -command ".fra.options yview"
41 listbox .fra.options -yscrollcommand ".fra.scroll set" -relief sunken -bd 2
42 pack .fra.label
43 pack .fra.options -side left
44 pack .fra.scroll -side right -fill y
45 bind .fra.options <Double-1> "set selected_option \[lindex \[selection get\] 0\]"
46 frame .option_edit
48 proc msg a {global $a
49 sendgnu [format "%s\n\nreplot\n" [expr $$a]] ;
50 set $a ""
51 getoptions}
53 proc mkOption_edit {a b} {
54 global $b
55 label $a.label -text "Edit: "
56 entry $a.entry -width 20 -relief sunken -bd 2 -textvariable $b
57 bind $a.entry <Return> "msg $b"
58 pack $a.label $a.entry -side left -padx 1m -pady 2m
61 mkOption_edit .option_edit selected_option
64 getoptions
66 button .exit -text "Exit" -command {
67 global done
68 sendgnu "exit\n"
69 set done 1
70 destroy .
73 button .saveps -text "Save gnuplot.ps" -command {
74 sendgnu "set output 'gnuplot.ps';set terminal postscript ; replot\n"
75 sendgnu "set terminal x11 ; replot; \n"
78 button .printps -text "Print -Plw8" -command {
79 sendgnu {set output '|lpr -Plw8';set terminal postscript ; replot}
80 sendgnu "set terminal x11 ; replot; \n"
83 button .replot -text "Replot" -command {
84 sendgnu {set terminal x11; replot \n}
89 button .save -text "save gnuplot.out" -command {
90 sendgnu "save 'gnuplot.out'\n"
93 scale .rotxscale -label "xrotation" \
94 -orient horizontal -length 200 -from 0 -to 180 \
95 -command gnuPlotsetview -tickinterval 60
96 scale .rotzscale -label "zrotation" \
97 -orient horizontal -length 200 -from 0 -to 360 \
98 -command gnuPlotsetview -tickinterval 120
100 #.rotxscale set $xrot
101 #.rotzscale set $zrot
103 proc gnuPlotsetview value {
104 sendgnu [format "set view %d,%d\nreplot\n" [.rotxscale get] [.rotzscale get]]}
106 pack .exit .saveps .printps .rotxscale .rotzscale .fra .option_edit .save
107 set done 0
108 tkwait variable done