comparison clients/editor/scripts/gui/input.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 8b125ec749d7
comparison
equal deleted inserted replaced
254:10b5f7f36dd4 255:51cc05d862f2
1 import pychan
2 import pychan.widgets as widgets
3
4 class InputDialog(object):
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, onCancel):
10 self._callback = onEntry
11 self._cancelCallback = onCancel
12
13 self._widget = pychan.loadXML('gui/input.xml')
14
15 self._widget.mapEvents({
16 'okButton' : self._complete,
17 'cancelButton' : self._cancel
18 })
19
20 self._widget.distributeInitialData({
21 'prompt' : prompt
22 })
23 self._widget.show()
24
25 def _complete(self):
26 self._callback(self._widget.collectData('inputBox'))
27 self._widget.hide()
28
29 def _cancel(self):
30 self._cancelCallback()
31 self._widget.hide()
32