Mercurial > fife-parpg
diff clients/pychan_demo/dynamic.py @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children | 97d6946bd917 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/clients/pychan_demo/dynamic.py Sun Jun 29 18:44:17 2008 +0000 @@ -0,0 +1,45 @@ +#!/usr/bin/env python +# coding: utf-8 + +import sys, os, re + +def _jp(path): + return os.path.sep.join(path.split('/')) + +_paths = ('../../engine/swigwrappers/python', '../../engine/extensions') +for p in _paths: + if p not in sys.path: + sys.path.append(_jp(p)) + +import fife +import fifelog +import settings + +import pychan + +from pychan_test import PyChanExample + +class DynamicExample(PyChanExample): + def __init__(self): + super(DynamicExample,self).__init__('content/gui/dynamic.xml') + + def start(self): + self.widget = pychan.loadXML(self.xmlFile) + self.widget.mapEvents({ + 'okButton' :self.stop, + 'addButton' :self.addLabel, + }) + self.labelBox = self.widget.findChild(name="labelBox") + self.widget.show() + + def addLabel(self): + # Code to check text wrapping code in FIFE + label = pychan.widgets.Label(max_size=(200,1000),wrap_text=True) + label.text = self.widget.collectData('labelText') + label.capture(self.removeLabel) + self.labelBox.addChild( label ) + self.widget.adaptLayout() + + def removeLabel(self,widget=None): + widget._parent.removeChild(widget) + self.widget.adaptLayout()