author | Radek Brich <radek.brich@devl.cz> |
Mon, 20 Feb 2012 18:15:13 +0100 | |
changeset 29 | c0cdef06fd16 |
parent 28 | feee783d4fc5 |
child 45 | 43b2279b06e1 |
permissions | -rwxr-xr-x |
19 | 1 |
#!/usr/bin/env python3 |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
28
feee783d4fc5
DriverPygame: output to character buffer, draw whole screen at once.
Radek Brich <radek.brich@devl.cz>
parents:
19
diff
changeset
|
4 |
import cProfile, pstats |
19 | 5 |
import locale |
6 |
import os |
|
7 |
||
8 |
from tuikit.application import Application |
|
9 |
from tuikit.window import Window |
|
10 |
from tuikit.button import Button |
|
11 |
||
12 |
||
13 |
class MyApplication(Application): |
|
14 |
def __init__(self): |
|
15 |
Application.__init__(self) |
|
16 |
self.top.connect('keypress', self.globalkeypress) |
|
17 |
||
18 |
#edit = EditField(50, 'DlouhyTest12') |
|
19 |
#self.top.add(edit) |
|
20 |
||
21 |
win = Window() |
|
22 |
self.top.add(win) |
|
23 |
||
24 |
button = Button('click!') |
|
25 |
win.add(button) |
|
26 |
button.x = 10 |
|
27 |
button.y = 7 |
|
28 |
||
29 |
button.connect('click', self.buttonclick) |
|
30 |
self.button = button |
|
31 |
||
32 |
subwin = Window(8,8) |
|
33 |
win.add(subwin) |
|
34 |
||
35 |
||
36 |
def buttonclick(self): |
|
37 |
self.button.label = 'YES' |
|
38 |
||
39 |
||
40 |
def globalkeypress(self, keyname, char): |
|
41 |
if keyname == 'escape': |
|
42 |
self.terminate() |
|
43 |
||
44 |
||
45 |
if __name__ == '__main__': |
|
46 |
locale.setlocale(locale.LC_ALL, '') |
|
47 |
os.environ['ESCDELAY'] = '25' # do not wait 1 second after pressing Escape key |
|
48 |
app = MyApplication() |
|
28
feee783d4fc5
DriverPygame: output to character buffer, draw whole screen at once.
Radek Brich <radek.brich@devl.cz>
parents:
19
diff
changeset
|
49 |
#app.start() |
feee783d4fc5
DriverPygame: output to character buffer, draw whole screen at once.
Radek Brich <radek.brich@devl.cz>
parents:
19
diff
changeset
|
50 |
|
29
c0cdef06fd16
Import only one driver from application.
Radek Brich <radek.brich@devl.cz>
parents:
28
diff
changeset
|
51 |
cProfile.run('app.start()', 'demo_window.appstats') |
c0cdef06fd16
Import only one driver from application.
Radek Brich <radek.brich@devl.cz>
parents:
28
diff
changeset
|
52 |
p = pstats.Stats('demo_window.appstats') |
28
feee783d4fc5
DriverPygame: output to character buffer, draw whole screen at once.
Radek Brich <radek.brich@devl.cz>
parents:
19
diff
changeset
|
53 |
p.sort_stats('time', 'cumulative').print_stats(20) |
19 | 54 |