comparison clients/pychan_demo/pychan_test.py @ 143:fe7ff4808529

- added guichan slider widget to pychan gui wrapper - added new attribute class to attrs.py (FloatAttr) - added demo to pychan demo client NOTE: - demo isn't nice yet - but I'll refactor the client anyway
author chewie@33b003aa-7bff-0310-803a-e67f0ece8222
date Tue, 07 Oct 2008 02:12:57 +0000
parents 97d6946bd917
children bb9902910067
comparison
equal deleted inserted replaced
142:816b17db2bec 143:fe7ff4808529
46 self.gui = pychan.loadXML('gui/demoapp.xml') 46 self.gui = pychan.loadXML('gui/demoapp.xml')
47 47
48 eventMap = { 48 eventMap = {
49 'creditsLink' : self.showCredits, 49 'creditsLink' : self.showCredits,
50 'closeButton' : self.quit, 50 'closeButton' : self.quit,
51 'demoList' : self.selectExample 51 'demoList' : self.selectExample,
52 'slider': self.test_slider
52 } 53 }
53 self.gui.mapEvents(eventMap) 54 self.gui.mapEvents(eventMap)
54 55
55 from dynamic import DynamicExample 56 from dynamic import DynamicExample
56 from styling import StylingExample 57 from styling import StylingExample
63 } 64 }
64 self.demoList = self.gui.findChild(name='demoList') 65 self.demoList = self.gui.findChild(name='demoList')
65 self.demoList.items += self.examples.keys() 66 self.demoList.items += self.examples.keys()
66 self.gui.show() 67 self.gui.show()
67 68
69 self.slider = self.gui.findChild(name='slider')
70 self.slider_value = self.gui.findChild(name='slider_value')
71
68 self.currentExample = None 72 self.currentExample = None
69 self.creditsWidget = None 73 self.creditsWidget = None
70 74
71 def selectExample(self): 75 def selectExample(self):
72 if self.demoList.selected_item is None: return 76 if self.demoList.selected_item is None: return
76 self.gui.findChild(name="xmlSource").text = open(self.currentExample.xmlFile).read() 80 self.gui.findChild(name="xmlSource").text = open(self.currentExample.xmlFile).read()
77 self.currentExample.start() 81 self.currentExample.start()
78 82
79 def showCredits(self): 83 def showCredits(self):
80 print pychan.loadXML('gui/credits.xml').execute({ 'okButton' : "Yay!" }) 84 print pychan.loadXML('gui/credits.xml').execute({ 'okButton' : "Yay!" })
85
86 def test_slider(self):
87 self.slider_value._setText( str(self.slider.getValue()) )
81 88
82 class TestXMLApplication(basicapplication.ApplicationBase): 89 class TestXMLApplication(basicapplication.ApplicationBase):
83 """ 90 """
84 Test Application. Run the pychan_test.py file 91 Test Application. Run the pychan_test.py file
85 with the XML file you want to load as argument. 92 with the XML file you want to load as argument.