~toolpart/+junk/pythoncard

« back to all changes in this revision

Viewing changes to samples/helpfulWrappers/helpfulWrappers.py

  • Committer: Bazaar Package Importer
  • Author(s): Sandro Tosi
  • Date: 2010-03-04 23:55:10 UTC
  • mfrom: (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100304235510-3v6lbhzwrgm0pcca
Tags: 0.8.2-1
* QA upload.
* New upstream release
* debian/control
  - set maintainer to QA group
  - set Homepage field, removing the URL from packages description
  - bump versioned b-d-i on python-support, to properly support Python module
  - replace b-d on python-all-dev with python-all, since building only
    arch:all packages
  - replace Source-Version substvar with source:Version
  - add ${misc:Depends} to binary packages Depends
* debian/watch
  - updated to use the SourceForge redirector; thanks to Raphael Geissert for
    the report and to Dario Minnucci for the patch; Closes: #449904
* debian/{pythoncard-doc, python-pythoncard}.install
  - use wildcards instead of site-packages to fix build with python 2.6;
    thanks to Ilya Barygin for the report and patch; Closes: #572332
* debian/pythoncard-doc.doc-base
  - set section to Programmin/Python
* debian/pythoncard-tools.menu
  - set menu main section to Applications
* debian/pythoncard-tools.postinst
  - removed, needed only to update the menu, but it's now created by debhelper

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
"""
 
4
__version__ = "$Revision: 1.3 $"
 
5
__date__ = "$Date: 2005/12/26 19:08:03 $"
 
6
"""
 
7
 
 
8
# sample to demonstrate usage of the "helpful" wrappers in helpful.py
 
9
from PythonCard import model, helpful
 
10
 
 
11
rsrc = {'application':{'type':'Application',
 
12
          'name':'testmultibuttondialog',
 
13
    'backgrounds': [
 
14
    {'type':'Background',
 
15
          'name':'bgMin',
 
16
          'title':'Demo of Helpful wrappers',
 
17
          'size':(300, 100),
 
18
         'components': [
 
19
 
 
20
       {'type':'Button',
 
21
           'name':'popup',
 
22
           'position':(100,10),
 
23
           'label':'Test pop-ups!',
 
24
           'toolTip':'try this - context-click and the pop-up will appear',
 
25
           },
 
26
 
 
27
       {'type':'Button',
 
28
           'name':'buttons',
 
29
           'position':(50,50),
 
30
           'label':'Test buttons!',
 
31
           },
 
32
 
 
33
       {'type':'Button',
 
34
           'name':'boxes',
 
35
           'position':(150,50),
 
36
           'label':'Test boxes!',
 
37
           },
 
38
 
 
39
 
 
40
] # end components
 
41
} # end background
 
42
] # end backgrounds
 
43
} }
 
44
 
 
45
class MyBackground(model.Background):
 
46
 
 
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) ]
 
49
        pass
 
50
 
 
51
    def on_popup_mouseClick(self, event):
 
52
        print self.boxes
 
53
 
 
54
    def on_popup_mouseContextDown(self, event):
 
55
        selected = helpful.popUpMenu(self, ['this', 'set', 'of', 'strings'], self.components.popup.position)
 
56
        if selected:
 
57
            print "Selected item was '"+selected+"'"
 
58
        else:
 
59
            print "Nothing selected."
 
60
 
 
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)
 
64
        
 
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)
 
68
 
 
69
 
 
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
 
74
        
 
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
 
78
 
 
79
 
 
80
if __name__ == '__main__':
 
81
   app = model.Application(MyBackground, None, rsrc)
 
82
   app.MainLoop()