Mercurial > fife-parpg
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 #!/usr/bin/env python | |
2 # coding: utf-8 | |
3 | |
4 import sys, os, re | |
5 | |
6 def _jp(path): | |
7 return os.path.sep.join(path.split('/')) | |
8 | |
9 _paths = ('../../engine/swigwrappers/python', '../../engine/extensions') | |
10 for p in _paths: | |
11 if p not in sys.path: | |
12 sys.path.append(_jp(p)) | |
13 | |
14 import fife | |
15 import fifelog | |
16 import settings | |
17 | |
18 import pychan | |
19 | |
20 from pychan_test import PyChanExample | |
21 | |
22 class DynamicExample(PyChanExample): | |
23 def __init__(self): | |
24 super(DynamicExample,self).__init__('content/gui/dynamic.xml') | |
25 | |
26 def start(self): | |
27 self.widget = pychan.loadXML(self.xmlFile) | |
28 self.widget.mapEvents({ | |
29 'okButton' :self.stop, | |
30 'addButton' :self.addLabel, | |
31 }) | |
32 self.labelBox = self.widget.findChild(name="labelBox") | |
33 self.widget.show() | |
34 | |
35 def addLabel(self): | |
36 # Code to check text wrapping code in FIFE | |
37 label = pychan.widgets.Label(max_size=(200,1000),wrap_text=True) | |
38 label.text = self.widget.collectData('labelText') | |
39 label.capture(self.removeLabel) | |
40 self.labelBox.addChild( label ) | |
41 self.widget.adaptLayout() | |
42 | |
43 def removeLabel(self,widget=None): | |
44 widget._parent.removeChild(widget) | |
45 self.widget.adaptLayout() |