author | Radek Brich <radek.brich@devl.cz> |
Wed, 02 Jan 2013 11:48:36 +0100 | |
changeset 44 | d77f1ae3786c |
parent 42 | 0224ce40792f |
child 45 | 43b2279b06e1 |
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 |
|
42
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
17 |
self.top.layout = VerticalLayout(homogeneous=False) |
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
|
18 |
|
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
|
19 |
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
|
20 |
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
|
21 |
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
|
22 |
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
|
23 |
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
|
24 |
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
|
25 |
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
|
26 |
|
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
|
27 |
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
|
28 |
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
|
29 |
hbox1.sizereq.h = 2 |
42
0224ce40792f
Make Container.layout a property.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
30 |
hbox1.layout = HorizontalLayout(homogeneous=homogeneous, spacing=spacing) |
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
|
31 |
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
|
32 |
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
|
33 |
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
|
34 |
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
|
35 |
|
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
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
|
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 |
|
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 |
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
|
42 |
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
|
43 |
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
|
44 |