Mercurial > fife-parpg
comparison clients/editor/input.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 | 28532ae6f9f6 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 import pychan | |
2 import pychan.widgets as widgets | |
3 | |
4 class Input(): | |
5 """ | |
6 Input supplies a text box for entering data. The result is passed to onEntry. | |
7 onEntry - the function to call when a input is complete. Accepts one argument: a string of text. | |
8 """ | |
9 def __init__(self, prompt, onEntry): | |
10 self._callback = onEntry | |
11 | |
12 self._widget = pychan.loadXML('content/gui/input.xml') | |
13 | |
14 self._widget.mapEvents({ | |
15 'okButton' : self._complete, | |
16 'cancelButton' : self._widget.hide | |
17 }) | |
18 | |
19 self._widget.distributeInitialData({ | |
20 'prompt' : prompt | |
21 }) | |
22 self._widget.show() | |
23 | |
24 def _complete(self): | |
25 self._callback(self._widget.collectData('inputBox')) | |
26 self._widget.hide() | |
27 |