4
__version__ = "$Revision: 1.3 $"
5
__date__ = "$Date: 2005/12/26 19:08:03 $"
8
# sample to demonstrate usage of the "helpful" wrappers in helpful.py
9
from PythonCard import model, helpful
11
rsrc = {'application':{'type':'Application',
12
'name':'testmultibuttondialog',
16
'title':'Demo of Helpful wrappers',
23
'label':'Test pop-ups!',
24
'toolTip':'try this - context-click and the pop-up will appear',
30
'label':'Test buttons!',
36
'label':'Test boxes!',
45
class MyBackground(model.Background):
47
def on_initialize(self, event):
48
self.boxes = [ ("already", False, 'already has a tooltip'), ("later", True), ("a long string to check sizing", True), "just a string", ("c", True), ("d", True), ("a1", True), ("a2", True), ("a3", True) ]
51
def on_popup_mouseClick(self, event):
54
def on_popup_mouseContextDown(self, event):
55
selected = helpful.popUpMenu(self, ['this', 'set', 'of', 'strings'], self.components.popup.position)
57
print "Selected item was '"+selected+"'"
59
print "Nothing selected."
61
def on_buttons_mouseClick(self, event):
62
result = helpful.multiButtonDialog(self, 'some question', ['OK', 'Not OK', "Cancel"], "Test Dialog Title")
63
print "Dialog result:\naccepted: %s\ntext: %s" % (result.accepted, result.text)
65
result = helpful.multiButtonDialog(self, 'Dad, can I go to the movies tonight', \
66
['Yes', 'No', 'Maybe', ('Ask me later', 'procrastination will be better tomorrow'), 'Ask your mum'], "Movies Dialog Title")
67
print "Dialog result:\naccepted: %s\ntext: %s" % (result.accepted, result.text)
70
def on_boxes_mouseClick(self, event):
71
boxes = [ ("already", False), ("later", True) ]
72
result = helpful.multiCheckBoxDialog(self, boxes, "Test Boxes Dialog Title")
73
print "Dialog result:\naccepted: %s\n" % (result.accepted), result.boxes
75
result = helpful.multiCheckBoxDialog(self, self.boxes, "Test Boxes Dialog Title")
76
print "Dialog result:\naccepted: %s\n" % (result.accepted), result.boxes
77
self.boxes = result.boxes
80
if __name__ == '__main__':
81
app = model.Application(MyBackground, None, rsrc)