Mercurial > fife-parpg
comparison clients/pychan_demo/sliders.py @ 255:51cc05d862f2
Merged editor_rewrite branch to trunk.
This contains changes that may break compatibility against existing clients.
For a list of changes that may affect your client, see: http://wiki.fifengine.de/Changes_to_pychan_and_FIFE_in_editor_rewrite_branch
author | cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 08 Jun 2009 16:00:02 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
254:10b5f7f36dd4 | 255:51cc05d862f2 |
---|---|
1 # -*- coding: utf-8 -*- | |
2 | |
3 from pychan_test import PyChanExample | |
4 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 }) |