--- a/demo_input.py Fri Feb 01 09:34:15 2013 +0100
+++ b/demo_input.py Sat Feb 02 12:54:27 2013 +0100
@@ -4,7 +4,9 @@
import locale
locale.setlocale(locale.LC_ALL, '')
-from tuikit import Application, TextEdit
+from tuikit.application import Application
+from tuikit.scrollview import ScrollView
+from tuikit.editbox import EditBox
class MyApplication(Application):
@@ -12,23 +14,23 @@
Application.__init__(self)
self.text = ''
- self.textedit = TextEdit(self.text)
- self.top.add(self.textedit, halign='fill', valign='fill')
+ self.editbox = EditBox(self.text)
+ scroll = ScrollView()
+ scroll.add(self.editbox)
+ self.top.add(scroll, halign='fill', valign='fill')
- editbox = self.textedit.editbox
- editbox.add_handler('keypress', self.on_any_input)
- editbox.add_handler('mousedown', self.on_any_input)
- editbox.add_handler('mouseup', self.on_any_input)
- editbox.add_handler('mousewheel', self.on_any_input)
- editbox.add_handler('mousemove', self.on_any_input)
- editbox.add_handler('mousehover', self.on_any_input)
+ self.editbox.add_handler('keypress', self.on_any_input)
+ self.editbox.add_handler('mousedown', self.on_any_input)
+ self.editbox.add_handler('mouseup', self.on_any_input)
+ self.editbox.add_handler('mousewheel', self.on_any_input)
+ self.editbox.add_handler('mousemove', self.on_any_input)
+ self.editbox.add_handler('mousehover', self.on_any_input)
def on_any_input(self, ev):
- if ev.event_name == 'keypress' and ev.char == 'q':
+ if ev.event_name == 'keypress' and ev.keyname == 'escape':
self.terminate()
- self.text += ''.join((ev.event_name.ljust(10), ' : ', repr(ev), '\n'))
- self.textedit.settext(self.text)
- self.textedit.scrolltoend()
+ line = ''.join((ev.event_name.ljust(10), ' : ', repr(ev)))
+ self.editbox.add_line(line)
return True