demo_window.py
author Radek Brich <radek.brich@devl.cz>
Wed, 02 Jan 2013 11:48:36 +0100
changeset 44 d77f1ae3786c
parent 29 c0cdef06fd16
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 cProfile, pstats
import locale
import os

from tuikit.application import Application
from tuikit.window import Window
from tuikit.button import Button


class MyApplication(Application):
    def __init__(self):
        Application.__init__(self)
        self.top.connect('keypress', self.globalkeypress)

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

        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 __name__ == '__main__':
    locale.setlocale(locale.LC_ALL, '')
    os.environ['ESCDELAY'] = '25' # do not wait 1 second after pressing Escape key
    app = MyApplication()
    #app.start()
    
    cProfile.run('app.start()', 'demo_window.appstats')
    p = pstats.Stats('demo_window.appstats')
    p.sort_stats('time', 'cumulative').print_stats(20)