Download User Manual - AVC, Application View Controller

Transcript
AVC, Application View Controller
User Manual
12. Tk examples
12.1.
Spin box example
For a functional description of the graphical interface see the GTK+ “Spin button example“ at
page 27 .
12.1.1.
Python source
#!/usr/bin/python
# .copyright : (c) 2007 Fabrizio Pollastri
# .license
: GNU General Public License v3
from Tkinter import *
# Tk interface
from avc import *
# AVC
TCL_FILE = 'tk_spinbox.tcl'
# GUI description as tcl script
class Example(AVC):
"""
A spin control whose value is replicated into a label
"""
def __init__(self):
# create GUI
self.root = Tk()
self.root.eval('set argc {}; set argv {}; proc ::main {argc argv} {};')
self.root.tk.evalfile(TCL_FILE)
# terminate program at toplevel window destroy: connect toplevel
# destroy signal to termination handler.
self.root.bind_class('Toplevel','<Destroy>',lambda event: self.root.quit())
# the variable holding the spin control value
self.spin_value = 0
#### MAIN
example = Example()
example.avc_init()
Tkinter.mainloop()
Fabrizio Pollastri
# instantiate the application
# connect widgets with variables
# run Tk event loop until quit
64/115