author | Radek Brich <radek.brich@devl.cz> |
Sat, 29 Dec 2012 12:16:06 +0100 | |
changeset 41 | 37b7dfc3eae6 |
parent 16 | 8791a7da6835 |
child 42 | 0224ce40792f |
permissions | -rwxr-xr-x |
16
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python3 |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
3 |
|
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
4 |
import locale |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
5 |
locale.setlocale(locale.LC_ALL, '') |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
6 |
|
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
7 |
from tuikit import * |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
8 |
|
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
9 |
|
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
10 |
class MyApplication(Application): |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
11 |
def __init__(self): |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
12 |
Application.__init__(self) |
41
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
16
diff
changeset
|
13 |
self.top.connect('keypress', self.on_top_keypress) |
16
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
14 |
|
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
15 |
#self.top.borders = (1,1,1,1) |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
16 |
|
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
17 |
vert = VerticalLayout(homogeneous=False) |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
18 |
self.top.layout(vert) |
41
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
16
diff
changeset
|
19 |
|
16
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
20 |
self.buildrow() |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
21 |
self.buildrow(expand=True) |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
22 |
self.buildrow(expand=True, fill=True) |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
23 |
self.buildrow(homogeneous=True) |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
24 |
self.buildrow(homogeneous=True, fill=True) |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
25 |
self.buildrow(homogeneous=True, fill=True, spacing=1) |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
26 |
self.buildrow(homogeneous=True, fill=True, spacing=2) |
41
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
16
diff
changeset
|
27 |
|
16
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
28 |
def buildrow(self, homogeneous=False, spacing=0, expand=False, fill=False): |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
29 |
horz = HorizontalLayout(homogeneous=homogeneous, spacing=spacing) |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
30 |
hbox1 = Container() |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
31 |
hbox1.sizereq.h = 2 |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
32 |
hbox1.layout(horz) |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
33 |
self.top.add(hbox1) |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
34 |
for i in range(5): |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
35 |
btn = Button('Btn' + str(i) * i * i) |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
36 |
hbox1.add(btn, expand=expand, fill=fill) |
41
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
16
diff
changeset
|
37 |
|
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
16
diff
changeset
|
38 |
def on_top_keypress(self, ev): |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
16
diff
changeset
|
39 |
if ev.keyname == 'escape' or ev.char == 'q': |
16
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
40 |
self.terminate() |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
41 |
|
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
42 |
|
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
43 |
if __name__ == '__main__': |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
44 |
app = MyApplication() |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
45 |
app.start() |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
46 |