File: pytkdemo

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 (241 lines) | stat: -rwxr-xr-x 7,274 bytes parent folder | download | duplicates (3)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#!/usr/bin/env python3
# -*-python-*-
# Geoffrey Furnish
#
# A Python/Tk script to interactively run the various Python demos.

# Append to effective python path so that can find plplot modules.
import plplot_python_start

# Python 2 name is Tkinter, Python 3 name is tkinter (sigh).
import sys
if sys.version_info[:2] >= (3, 0):
    from tkinter import *
else:
    from Tkinter import *

# According to the discussion at
# <https://stackoverflow.com/questions/437589/how-do-i-unload-reload-a-python-module>
# reload is just part of Python2, it is part of the imp module (deprecated as of
# Python 3.4) for Python3 version < 3.4.0, and it is part of the importlib module
# that is available for Python3 version >= 3.4.0

if sys.version_info[:3] < (3, 0, 0):
    pass
elif  sys.version_info[:3] < (3, 4, 0):
    from imp import reload
else:
    from importlib import reload

import Pltk_init

import Plframe

import restore
import x00
import x01
import x02
import x03
import x04
import x05
import x06
import x07
import x08
import x09
import x10
import x11
import x12
import x13
##import x14
##import x15
import x16
##import x17
import x18
##import x19

class DemoApp(Frame):

    def __init__( s, master=None ):
        Frame.__init__( s, master )
        #print("Building the Python Tk demo application main window.")

        s.create_widgets()
        s.pack( expand=1, fill=BOTH )

        #plspause(1)

    def create_widgets(s):
        s.f = Frame(s)
        s.make_demo_bar( s.f )

        #print("Time to register the plframe with the interp...")
        Pltk_init.Pltk_init( s.tk.interpaddr() );

        s.plf = Plframe.PlXframe(s, width="17c", height="17c" )

        s.f2 = Frame(s)
        s.f2.clone = Button( s.f2, text="Clone", command=s.clone )
        s.f2.clone.pack( side=LEFT, expand=1, fill=X )
        s.f2.reload = Button( s.f2, text="Reload", command=s.reload )
        s.f2.reload.pack( side=LEFT, expand=1, fill=X )
        s.f2.quit = Button( s.f2, text="Dismiss", command=s.master.destroy )
        s.f2.quit.pack( side=LEFT, expand=1, fill=X )
        s.f2.pack( side=BOTTOM, fill=X )

        s.f.pack( side=LEFT )
        s.plf.pack( side=RIGHT, expand=1, fill=BOTH )

    def make_demo_bar( s, f ):
        f.x00 = Button( f, text="Example 0", command=s.demo_x00 )
        f.x00.pack( expand=1, fill=X )
        f.x01 = Button( f, text="Example 1", command=s.demo_x01 )
        f.x01.pack( expand=1, fill=X )
        f.x02 = Button( f, text="Example 2", command=s.demo_x02 )
        f.x02.pack( expand=1, fill=X )
        f.x03 = Button( f, text="Example 3", command=s.demo_x03 )
        f.x03.pack( expand=1, fill=X )
        f.x04 = Button( f, text="Example 4", command=s.demo_x04 )
        f.x04.pack( expand=1, fill=X )
        f.x05 = Button( f, text="Example 5", command=s.demo_x05 )
        f.x05.pack( expand=1, fill=X )
        f.x06 = Button( f, text="Example 6", command=s.demo_x06 )
        f.x06.pack( expand=1, fill=X )
        f.x07 = Button( f, text="Example 7", command=s.demo_x07 )
        f.x07.pack( expand=1, fill=X )
        f.x08 = Button( f, text="Example 8", command=s.demo_x08 )
        f.x08.pack( expand=1, fill=X )
        f.x09 = Button( f, text="Example 9", command=s.demo_x09 )
        f.x09.pack( expand=1, fill=X )
        f.x10 = Button( f, text="Example 10", command=s.demo_x10 )
        f.x10.pack( expand=1, fill=X )
        f.x11 = Button( f, text="Example 11", command=s.demo_x11 )
        f.x11.pack( expand=1, fill=X )
        f.x12 = Button( f, text="Example 12", command=s.demo_x12 )
        f.x12.pack( expand=1, fill=X )
        f.x13 = Button( f, text="Example 13", command=s.demo_x13 )
        f.x13.pack( expand=1, fill=X )
        f.x14 = Button( f, text="Example 14", command=s.demo_x14, state='disabled' )
        f.x14.pack( expand=1, fill=X )
        f.x15 = Button( f, text="Example 15", command=s.demo_x15, state='disabled' )
        f.x15.pack( expand=1, fill=X )
        f.x16 = Button( f, text="Example 16", command=s.demo_x16 )
        f.x16.pack( expand=1, fill=X )
        f.x17 = Button( f, text="Example 17", command=s.demo_x17, state='disabled' )
        f.x17.pack( expand=1, fill=X )
        f.x18 = Button( f, text="Example 18", command=s.demo_x18 )
        f.x18.pack( expand=1, fill=X )
        f.x19 = Button( f, text="Example 19", command=s.demo_x19, state='disabled' )
        f.x19.pack( expand=1, fill=X )

        # Others here.

##      f.quit = Button( f, text="Quit", command=f.quit )
##      f.quit.pack( expand=1, fill=X )

## A nice addition would be for these functions to not only call the
## demos, but to also stuff their source code into a text widget, so
## the user can easily see the correspondence between the source and
## the visual effects.

    def demo_x00(s):
        x00.main( s.plf )
        restore.main( s.plf )
    def demo_x01(s):
        x01.main( s.plf )
        restore.main( s.plf )
    def demo_x02(s):
        x02.main( s.plf )
        restore.main( s.plf )
    def demo_x03(s):
        x03.main( s.plf )
        restore.main( s.plf )
    def demo_x04(s):
        x04.main( s.plf )
        restore.main( s.plf )
    def demo_x05(s):
        x05.main( s.plf )
        restore.main( s.plf )
    def demo_x06(s):
        x06.main( s.plf )
        restore.main( s.plf )
    def demo_x07(s):
        x07.main( s.plf )
        restore.main( s.plf )
    def demo_x08(s):
        x08.main( s.plf )
        restore.main( s.plf )
    def demo_x09(s):
        x09.main( s.plf )
        restore.main( s.plf )
    def demo_x10(s):
        x10.main( s.plf )
        restore.main( s.plf )
    def demo_x11(s):
        x11.main( s.plf )
        restore.main( s.plf )
    def demo_x12(s):
        x12.main( s.plf )
        restore.main( s.plf )
    def demo_x13(s):
        x13.main( s.plf )
        restore.main( s.plf )
    def demo_x14(s):
        x14.main( s.plf )
        restore.main( s.plf )
    def demo_x15(s):
        x15.main( s.plf )
        restore.main( s.plf )
    def demo_x16(s):
        x16.main( s.plf )
        restore.main( s.plf )
    def demo_x17(s):
        x17.main( s.plf )
        restore.main( s.plf )
    def demo_x18(s):
        x18.main( s.plf )
        restore.main( s.plf )
    def demo_x19(s):
        x19.main( s.plf )
        restore.main( s.plf )

    def clone(s):
        "Make a new instance of this demo megawidget."

        take2 = DemoApp( Toplevel() )
        pass

    def reload(s):
        """Reload all the demo modules.

        Facilitates modification of the demos, which is most useful
        during the period of implementing the demos in Python."""

        reload( x00 )
        reload( x01 )
        reload( x02 )
        reload( x03 )
        reload( x04 )
        reload( x05 )
        reload( x06 )
        reload( x07 )
        reload( x08 )
        reload( x09 )
        reload( x10 )
        reload( x11 )
        reload( x12 )
        reload( x13 )
##      reload( x14 )
##      reload( x15 )
        reload( x16 )
##      reload( x17 )
        reload( x18 )
##      reload( x19 )

        # Let's also reload the Plframe module, so we can hack on that
        # freely too.

        #reload( Plframe )
        # Doesn't work, don't know why.  Grrr.

demo = DemoApp()
demo.mainloop()