editor.py
author Radek Brich <radek.brich@devl.cz>
Sun, 10 Apr 2011 22:54:38 +0200
changeset 5 ae128c885d0f
parent 2 684cdc352562
permissions -rwxr-xr-x
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.

#!/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.globalkeypress)

        #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 globalkeypress(self, keyname, char):
        if keyname == 'escape':
            self.terminate()
        if keyname == 'f1':
            self.textedit.settext('%s' % self.top.focuschild)
            self.textedit.redraw()
            


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