Mercurial > fife-parpg
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/pychan_demo/sliders.py Mon Jan 11 23:34:52 2010 +0000 @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +from pychan_test import PyChanExample +from fife.extensions import pychan + +class SliderExample(PyChanExample): + def __init__(self): + super(SliderExample,self).__init__('gui/slider.xml') + def start(self): + self.widget = pychan.loadXML(self.xmlFile) + self.widget.mapEvents({ + 'xslider': self.update, + 'yslider': self.update, + 'closeButton':self.stop, + }) + self.update() + self.widget.show() + def update(self): + """ + Update Icon position from the sliders. + """ + icon = self.widget.findChild(name="icon") + # sliders have floats, guichan is picky and wants ints + # so we convert here. + icon.position = map(int, self.widget.collectData('xslider','yslider')) + # we distribute to the labels with the x,y value. + # That's user visible 'text' - so pychan wants unicode. + self.widget.distributeInitialData({ + 'xvalue' : unicode(icon.x), + 'yvalue' : unicode(icon.y), + })