Download User Manual - AVC, Application View Controller

Transcript
AVC, Application View Controller
from avc import *
User Manual
# AVC for Swing
class Example(AVC):
"""
A spinner whose value is replicated into a label
"""
def __init__(self):
# create GUI
root = swing.JFrame('AVC Swing spinner example',size=(320,60),
defaultCloseOperation = swing.JFrame.EXIT_ON_CLOSE)
root.layout = awt.FlowLayout()
root.add(swing.JLabel('%s',name='spin_value__label',preferredSize=(80,20)))
root.add(swing.JSpinner(name='spin_value__spinner',preferredSize=(80,20)))
root.show()
# the variable holding the spinner value
self.spin_value = 0
#### MAIN
example = Example()
example.avc_init()
# instantiate the application
# connect widgets with variables
#### END
The key points of the example regarding AVC are the same of the Swing “button example”,
only the following differs.
●
●
In GUI creation statements, the same name 'spin_value' was given to the spinner and
to the label widgets.
A integer variable with an initial value of 0 and name 'spin_value' is declared in the
application (self.spin_value = 0).
Example files in directory 'examples' of distribution: program 'swing_spinner.py'.
14.11.
Table example
This example shows the display capabilities of a table widget of 2D tabular data arranged as
explained in “List view“. The rows of the list view are rolled down by one position every 2
seconds. For each row, it is showed the connected python data equivalent to data displayed by
each widget. The same data structure is also displayed as string into a label widget.
14.11.1.
Jython source
#!/usr/bin/env jython
# .copyright : (c) 2009 Fabrizio Pollastri.
Fabrizio Pollastri
105/115