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
|
#!/usr/bin/env python
# -*-python-*-
# Geoffrey Furnish
#
# A Python/Tk script to interactively run the various Python demos.
from Tkinter import *
from plplot import *
from plplot_widget import *
import Plframe
from Plframe import *
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( s.tk.interpaddr() );
s.plf = 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.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,
state='disabled' )
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,
state='disabled' )
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_x01(s):
x01.main( s.plf )
def demo_x02(s):
x02.main( s.plf )
def demo_x03(s):
x03.main( s.plf )
def demo_x04(s):
x04.main( s.plf )
def demo_x05(s):
x05.main( s.plf )
def demo_x06(s):
x06.main( s.plf )
def demo_x07(s):
x07.main( s.plf )
def demo_x08(s):
x08.main( s.plf )
def demo_x09(s):
x09.main( s.plf )
def demo_x10(s):
x10.main( s.plf )
def demo_x11(s):
x11.main( s.plf )
def demo_x12(s):
x12.main( s.plf )
def demo_x13(s):
x13.main( s.plf )
def demo_x14(s):
x14.main( s.plf )
def demo_x15(s):
x15.main( s.plf )
def demo_x16(s):
x16.main( s.plf )
def demo_x17(s):
x17.main( s.plf )
def demo_x18(s):
x18.main( s.plf )
def demo_x19(s):
x19.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 hte period of implementing the demos in Python."""
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()
|