Mercurial > fife-parpg
comparison clients/pychan_demo/pychan_test.py @ 228:756b895e1dab
Merged unicode-support back into trunk.
Now all GUI/visible strings should be unicode.
Internal strings unchanged.
Remember to use a font that actually has the desired codepoints.
Current default unicode policiy is 'ignore'.
author | phoku@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 21 Mar 2009 10:38:11 +0000 |
parents | c050f257cec3 |
children | 51cc05d862f2 |
comparison
equal
deleted
inserted
replaced
227:d642169490f7 | 228:756b895e1dab |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # -*- coding: utf-8 -*- | |
2 # coding: utf-8 | 3 # coding: utf-8 |
3 # This is the pychan demo client for FIFE. | 4 # This is the pychan demo client for FIFE. |
4 | 5 |
5 import sys, os, re | 6 import sys, os, re |
6 | 7 |
34 def stop(self): | 35 def stop(self): |
35 if self.widget: | 36 if self.widget: |
36 self.widget.hide() | 37 self.widget.hide() |
37 self.widget = None | 38 self.widget = None |
38 | 39 |
39 def testTimer(): | 40 #def testTimer(): |
40 import timer | 41 #import timer |
41 timer.init( pychan.manager.hook.engine.getTimeManager() ) | 42 #timer.init( pychan.manager.hook.engine.getTimeManager() ) |
42 def spam(): | 43 #def spam(): |
43 print "SPAM SPAM" | 44 #print "SPAM SPAM" |
44 return 1 | 45 #return 1 |
45 repeater = timer.repeatCall(500,spam) | 46 #repeater = timer.repeatCall(500,spam) |
46 def stop_spam(): | 47 #def stop_spam(): |
47 repeater.stop() | 48 #repeater.stop() |
48 print "BACON EGGS AND SPAM" | 49 #print "BACON EGGS AND SPAM" |
49 timer.delayCall(5000,stop_spam) | 50 #timer.delayCall(5000,stop_spam) |
50 | 51 |
51 | 52 |
52 class DemoApplication(basicapplication.ApplicationBase): | 53 class DemoApplication(basicapplication.ApplicationBase): |
53 def __init__(self): | 54 def __init__(self): |
54 super(DemoApplication,self).__init__() | 55 super(DemoApplication,self).__init__() |
55 | 56 |
56 pychan.init(self.engine,debug=True) | 57 pychan.init(self.engine,debug=False) |
58 pychan.loadFonts("fonts/freefont.fontdef") | |
59 pychan.manager.setDefaultFont("FreeSans") | |
60 #pychan.manager.setDefaultFont("Kochi") | |
57 pychan.setupModalExecution(self.mainLoop,self.breakFromMainLoop) | 61 pychan.setupModalExecution(self.mainLoop,self.breakFromMainLoop) |
58 | 62 |
59 self.gui = pychan.loadXML('gui/demoapp.xml') | 63 self.gui = pychan.loadXML('gui/demoapp.xml') |
60 | 64 self.gui.findChild(name="xmlSource").font = "FreeMono" |
65 | |
61 eventMap = { | 66 eventMap = { |
62 'creditsLink' : self.showCredits, | 67 'creditsLink' : self.showCredits, |
63 'closeButton' : self.quit, | 68 'closeButton' : self.quit, |
64 'demoList' : self.selectExample, | 69 'demoList' : self.selectExample, |
65 'slider': self.test_slider | 70 'slider': self.test_slider |
89 self.slider = self.gui.findChild(name='slider') | 94 self.slider = self.gui.findChild(name='slider') |
90 self.slider_value = self.gui.findChild(name='slider_value') | 95 self.slider_value = self.gui.findChild(name='slider_value') |
91 | 96 |
92 self.currentExample = None | 97 self.currentExample = None |
93 self.creditsWidget = None | 98 self.creditsWidget = None |
94 testTimer() | |
95 | 99 |
96 def selectExample(self): | 100 def selectExample(self): |
97 if self.demoList.selected_item is None: return | 101 if self.demoList.selected_item is None: return |
98 print "selected",self.demoList.selected_item | 102 print "selected",self.demoList.selected_item |
99 if self.currentExample: self.currentExample.stop() | 103 if self.currentExample: self.currentExample.stop() |