SUIT/Python example file: demo.py

woc8r@maple.cs.virginia.edu
Thu, 10 Mar 94 17:05:52 EST

Here is the example file demo.py. It corresponds exactly to demo.c
distributed with SUIT.

import sys
import suit
import GP

## all words in the English language that contain the sequence "suit"

list=['besuit', 'cosuitor', 'countersuit', 'demisuit', 'dissuit','dissuitable', 'dissuited', 'Jesuit', 'Jesuited', 'Jesuitess','Jesuitic', 'Jesuitical', 'Jesuitically', 'Jesuitish','Jesuitism', 'Jesuitist', 'Jesuitize', 'Jesuitocracy','Jesuitry', 'lawsuit', 'lawsuiting', 'mispursuit', 'nonpursuit','nonsuit', 'outsuitor', 'overunsuitable', 'playsuit','presuitability', 'presuitable', 'presuitably', 'pursuit','pursuitmeter', 'repursuit', 'resuit', 'snowsuit', 'suit','suitability', 'suitable', 'suitableness', 'suitably','suitcase', 'suite', 'suithold', 'suiting', 'suitor','suitoress', 'suitorship', 'suity', 'swimsuit', 'undersuit', 'unjesuited', 'unjesuitical', 'unjesuitically', 'unsuit', 'unsuitability', 'unsuitable', 'unsuitableness', 'unsuitably', 'unsuited', 'unsuiting'];

################################################################################
##
## Demo program showing off all the built-in widgets.
##
################################################################################

################################################################################
## This "callback" routine is called when the user types in
## the text box.
################################################################################

def EchoText (obj):
print 'The user typed ',
print obj.getText(suit.CURRENT_VALUE)

################################################################################
## the main program
################################################################################

################################################################################
## This must be called before any objects can be created.
################################################################################
suit.init ('demo')

################################################################################
## We create a bunch of suit.Labels which are used to identify widgets
################################################################################
l1=suit.Label('SUIT')
l2=suit.Label('Color Chips Widget')
l3=suit.Label('Bounded Value Widget');
l4=suit.Label('Menu Widget');
l5=suit.Label('Type In Widget');
l6=suit.Label('Text Editor Widget');
l7=suit.Label('Scrollable List Widget');
l8=suit.Label('UVa Logo Widget');
l9=suit.Label('On/Off Switch Widget');
l10=suit.Label('Radio Button Widget');
l11=suit.Label('Button Widgets');

################################################################################
## Each of the following widgets allow you to specify a "call-back"
## routine (that you write) which is called each time the user
## interacts with the object (for example, moves a thermometer up or
## down. This demo program specifies None for them, since it's just
## a shell.
################################################################################
ball1=suit.BouncingBall ('first ball')
ball1.setBoolean ('animated', suit.TRUE)
ball2=suit.BouncingBall ('second ball')
ball2.setBoolean ('animated', suit.TRUE)
bv1=suit.BoundedValue ('my bounded value', None)
oo1=suit.OnOffSwitch ('my switch', None)
cc1=suit.ColorChips ('my color chips', None)
SuitList=suit.ScrollableList ('list of SUIT words', None)
SuitList.setTextList ('list', list)
logo1=suit.UVALogo ('my UVALogo')

################################################################################
## To show how callbacks work, we specify one for the text
## box. The callback routine takes one parameter, which is the
## SUIT_object altered by the user. By examining the properties of
## the passed object, the callback routine can do whatever is
## appropriate. The "EchoText" callback (found later in this file)
## simply prints out the text the user typed.
################################################################################
tib=suit.TypeInBox ('my typein box', EchoText)
te=suit.TextEditor ('my text editor', None)
te.setText('current value','This text editor\nsupports emacs-style\nkey bindings\n')

################################################################################
## Some widgets are "composite," such as menus and radio buttons.
################################################################################
menu=suit.PullDownMenu ('my menu')
choice1=menu.addToMenu ('Monday', None)
choice2=menu.addToMenu ('Tuesday', None)
choice3=menu.addToMenu ('Wednesday', None)
choice4=menu.addToMenu ('Thursday', None)
choice5=menu.addToMenu ('Friday', None)

radio=suit.RadioButtons ('my radio buttons', None)
radio.addButtonToRadioButtons ('Chocolate')
radio.addButtonToRadioButtons ('Vanilla')
radio.addButtonToRadioButtons ('Strawberry')
radio.addButtonToRadioButtons ('RockyRoad')

################################################################################
## These calls inserted only for the tutorial
################################################################################
p=suit.Polygon ('my poly')
p.setInteger ('number of sides', 7)
p.setBoolean ('filled', suit.TRUE)
p.setColor ('foreground color', 'red', suit.TRUE)
plabel=suit.Label ('Polygon Widget')

################################################################################
## After creating all the objects, we tell SUIT to begin the application.
################################################################################
done=suit.DoneButton (None)
abort=suit.AbortButton (None)
suit.beginStandardApplication()

___ ___
\ \ / / -=Bill Carlson=- | "I wanna decide who
\ \/ / | lives and who dies"
\ / INTERNET: woc8r@Virginia.EDU |
\__/ BITNET: woc8r@VIRGINIA | -Crow T. Robot