demo_editor.py
author Radek Brich <radek.brich@devl.cz>
Sat, 05 Jan 2013 16:47:30 +0100
changeset 49 1611c462c3e3
parent 45 43b2279b06e1
child 62 2f61931520c9
permissions -rwxr-xr-x
Update sdlterm: Optimize commit() - use two cell buffers, redraw only dirty cells, not everything. Fix keypress event, filter mousemove.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import locale
locale.setlocale(locale.LC_ALL, '')

import os

from tuikit.application import Application
from tuikit.editfield import EditField
from tuikit.textedit import TextEdit


class MyApplication(Application):
    def __init__(self):
        Application.__init__(self)
        self.top.add_handler('keypress', self.on_top_keypress)

        #edit = EditField(50, 'DlouhyTest12')
        #self.top.add(edit)

        t = open('tuikit/widget.py').read()
        textedit = TextEdit(100, 40, t)
        self.top.add(textedit)
        textedit.x = 2
        self.textedit = textedit

    def on_top_keypress(self, ev):
        if ev.keyname == 'escape':
            self.terminate()
            return True


if __name__ == '__main__':
    os.environ['ESCDELAY'] = '25' # do not wait 1 second after pressing Escape key
    app = MyApplication()
    app.start()