demo_editor.py
author Radek Brich <radek.brich@devl.cz>
Wed, 02 Jan 2013 11:48:36 +0100
changeset 44 d77f1ae3786c
parent 41 37b7dfc3eae6
child 45 43b2279b06e1
permissions -rwxr-xr-x
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.

#!/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.window import Window
from tuikit.button import Button
from tuikit.scrollbar import VScrollbar
from tuikit.textedit import TextEdit


class MyApplication(Application):
    def __init__(self):
        Application.__init__(self)
        self.top.connect('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

        #win = Window()
        #self.top.add(win)

        #button = Button('click!')
        #win.add(button)
        #button.x = 10
        #button.y = 7

        #button.connect('click', self.buttonclick)
        #self.button = button

        #subwin = Window(8,8)
        #win.add(subwin)


    def buttonclick(self):
        self.button.label = 'YES'


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


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