Mercurial > fife-parpg
annotate clients/pychan_demo/pychan_test.py @ 222:c050f257cec3
PyChan: Now Widgets may _in principle_ receive key events.
author | phoku@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 19 Mar 2009 20:14:49 +0000 |
parents | 54bfd1015b35 |
children | 756b895e1dab |
rev | line source |
---|---|
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 #!/usr/bin/env python |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 # coding: utf-8 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 # This is the pychan demo client for FIFE. |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 import sys, os, re |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 def _jp(path): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 return os.path.sep.join(path.split('/')) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 _paths = ('../../engine/swigwrappers/python', '../../engine/extensions') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 for p in _paths: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 if p not in sys.path: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 sys.path.append(_jp(p)) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 import fife |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 import fifelog |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 import basicapplication |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 import pychan |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 class PyChanExample(object): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 def __init__(self,xmlFile): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 self.xmlFile = xmlFile |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 self.widget = None |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 def start(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 self.widget = pychan.loadXML(self.xmlFile) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 eventMap = { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 'closeButton':self.stop, |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 'okButton' :self.stop |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 self.widget.mapEvents(eventMap, ignoreMissing = True) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 self.widget.show() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 def stop(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 if self.widget: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 self.widget.hide() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 self.widget = None |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 |
165
fbc55c6f57cf
(Convenient) Timers.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
159
diff
changeset
|
39 def testTimer(): |
fbc55c6f57cf
(Convenient) Timers.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
159
diff
changeset
|
40 import timer |
205
54bfd1015b35
* PyChan event handling rework (part I)
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
165
diff
changeset
|
41 timer.init( pychan.manager.hook.engine.getTimeManager() ) |
165
fbc55c6f57cf
(Convenient) Timers.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
159
diff
changeset
|
42 def spam(): |
fbc55c6f57cf
(Convenient) Timers.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
159
diff
changeset
|
43 print "SPAM SPAM" |
fbc55c6f57cf
(Convenient) Timers.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
159
diff
changeset
|
44 return 1 |
fbc55c6f57cf
(Convenient) Timers.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
159
diff
changeset
|
45 repeater = timer.repeatCall(500,spam) |
fbc55c6f57cf
(Convenient) Timers.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
159
diff
changeset
|
46 def stop_spam(): |
fbc55c6f57cf
(Convenient) Timers.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
159
diff
changeset
|
47 repeater.stop() |
fbc55c6f57cf
(Convenient) Timers.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
159
diff
changeset
|
48 print "BACON EGGS AND SPAM" |
fbc55c6f57cf
(Convenient) Timers.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
159
diff
changeset
|
49 timer.delayCall(5000,stop_spam) |
fbc55c6f57cf
(Convenient) Timers.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
159
diff
changeset
|
50 |
fbc55c6f57cf
(Convenient) Timers.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
159
diff
changeset
|
51 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 class DemoApplication(basicapplication.ApplicationBase): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 def __init__(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
54 super(DemoApplication,self).__init__() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 pychan.init(self.engine,debug=True) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 pychan.setupModalExecution(self.mainLoop,self.breakFromMainLoop) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 |
125
97d6946bd917
- prepared files for new dir structure
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
59 self.gui = pychan.loadXML('gui/demoapp.xml') |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
61 eventMap = { |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
62 'creditsLink' : self.showCredits, |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 'closeButton' : self.quit, |
143
fe7ff4808529
- added guichan slider widget to pychan gui wrapper
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
125
diff
changeset
|
64 'demoList' : self.selectExample, |
fe7ff4808529
- added guichan slider widget to pychan gui wrapper
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
125
diff
changeset
|
65 'slider': self.test_slider |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
67 self.gui.mapEvents(eventMap) |
157
bb9902910067
input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
143
diff
changeset
|
68 credits = self.gui.findChild(name="creditsLink") |
bb9902910067
input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
143
diff
changeset
|
69 credits.setEnterCallback(lambda w : credits._setText("CREDITS")) |
bb9902910067
input_rework merged!
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
143
diff
changeset
|
70 credits.capture(lambda : credits._setText("Credits"), event_name="mouseExited") |
222
c050f257cec3
PyChan: Now Widgets may _in principle_ receive key events.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
205
diff
changeset
|
71 def pr(event=None): |
c050f257cec3
PyChan: Now Widgets may _in principle_ receive key events.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
205
diff
changeset
|
72 print event |
c050f257cec3
PyChan: Now Widgets may _in principle_ receive key events.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
205
diff
changeset
|
73 self.gui.capture(pr,event_name="keyPressed") |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 from dynamic import DynamicExample |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
76 from styling import StylingExample |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
77 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
78 self.examples = { |
125
97d6946bd917
- prepared files for new dir structure
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
79 'Absolute Positioning' : PyChanExample('gui/absolute.xml'), |
159
c305c5eda7ed
Fix for scrollarea bug.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
157
diff
changeset
|
80 'All Widgets' : PyChanExample('gui/all_widgets.xml'), |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
81 'Basic Styling' : StylingExample(), |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
82 'Dynamic Widgets' : DynamicExample(), |
159
c305c5eda7ed
Fix for scrollarea bug.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
157
diff
changeset
|
83 'ScrollArea' : PyChanExample('gui/scrollarea.xml'), |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
84 } |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
85 self.demoList = self.gui.findChild(name='demoList') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
86 self.demoList.items += self.examples.keys() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
87 self.gui.show() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
88 |
143
fe7ff4808529
- added guichan slider widget to pychan gui wrapper
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
125
diff
changeset
|
89 self.slider = self.gui.findChild(name='slider') |
fe7ff4808529
- added guichan slider widget to pychan gui wrapper
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
125
diff
changeset
|
90 self.slider_value = self.gui.findChild(name='slider_value') |
fe7ff4808529
- added guichan slider widget to pychan gui wrapper
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
125
diff
changeset
|
91 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
92 self.currentExample = None |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
93 self.creditsWidget = None |
165
fbc55c6f57cf
(Convenient) Timers.
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
159
diff
changeset
|
94 testTimer() |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
95 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
96 def selectExample(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
97 if self.demoList.selected_item is None: return |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
98 print "selected",self.demoList.selected_item |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
99 if self.currentExample: self.currentExample.stop() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
100 self.currentExample = self.examples[self.demoList.selected_item] |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
101 self.gui.findChild(name="xmlSource").text = open(self.currentExample.xmlFile).read() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
102 self.currentExample.start() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
103 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
104 def showCredits(self): |
125
97d6946bd917
- prepared files for new dir structure
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
0
diff
changeset
|
105 print pychan.loadXML('gui/credits.xml').execute({ 'okButton' : "Yay!" }) |
143
fe7ff4808529
- added guichan slider widget to pychan gui wrapper
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
125
diff
changeset
|
106 def test_slider(self): |
fe7ff4808529
- added guichan slider widget to pychan gui wrapper
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
125
diff
changeset
|
107 self.slider_value._setText( str(self.slider.getValue()) ) |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
108 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
109 class TestXMLApplication(basicapplication.ApplicationBase): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
110 """ |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
111 Test Application. Run the pychan_test.py file |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
112 with the XML file you want to load as argument. |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
113 """ |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
114 def __init__(self,xmlfile): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
115 super(TestXMLApplication,self).__init__() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
116 pychan.init(self.engine,debug=True) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
117 self.widget = pychan.loadXML(xmlfile) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
118 self.widget.show() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
119 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
120 if __name__ == '__main__': |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
121 import sys |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
122 if len(sys.argv) == 2: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
123 app = TestXMLApplication(sys.argv[1]) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
124 else: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
125 app = DemoApplication() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
126 app.run() |