Mercurial > fife-parpg
comparison demos/pychan_demo/sliders.py @ 378:64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
author | vtchill@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 11 Jan 2010 23:34:52 +0000 |
parents | |
children | 70697641fca3 |
comparison
equal
deleted
inserted
replaced
377:fe6fb0e0ed23 | 378:64738befdf3b |
---|---|
1 # -*- coding: utf-8 -*- | |
2 | |
3 from pychan_test import PyChanExample | |
4 from fife.extensions import pychan | |
5 | |
6 class SliderExample(PyChanExample): | |
7 def __init__(self): | |
8 super(SliderExample,self).__init__('gui/slider.xml') | |
9 def start(self): | |
10 self.widget = pychan.loadXML(self.xmlFile) | |
11 self.widget.mapEvents({ | |
12 'xslider': self.update, | |
13 'yslider': self.update, | |
14 'closeButton':self.stop, | |
15 }) | |
16 self.update() | |
17 self.widget.show() | |
18 def update(self): | |
19 """ | |
20 Update Icon position from the sliders. | |
21 """ | |
22 icon = self.widget.findChild(name="icon") | |
23 # sliders have floats, guichan is picky and wants ints | |
24 # so we convert here. | |
25 icon.position = map(int, self.widget.collectData('xslider','yslider')) | |
26 # we distribute to the labels with the x,y value. | |
27 # That's user visible 'text' - so pychan wants unicode. | |
28 self.widget.distributeInitialData({ | |
29 'xvalue' : unicode(icon.x), | |
30 'yvalue' : unicode(icon.y), | |
31 }) |