author | Radek Brich <radek.brich@devl.cz> |
Fri, 14 Mar 2014 18:23:23 +0100 | |
changeset 82 | 2bead23b1262 |
parent 70 | db2eab0beb45 |
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 |
|
70
db2eab0beb45
Update drivers: Rename setcolor to defcolor, add real setcolor which ignores color stack.
Radek Brich <radek.brich@devl.cz>
parents:
63
diff
changeset
|
7 |
from tuikit import Application, VerticalLayout, HorizontalLayout, Button |
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
|
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) |
62
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
45
diff
changeset
|
13 |
|
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
45
diff
changeset
|
14 |
self.top = VerticalLayout(homogeneous=False) |
45
43b2279b06e1
Clean up Emitter class, simplify event handling. Fix Container.focusnext() method. Add events test (handler auto-registration, order).
Radek Brich <radek.brich@devl.cz>
parents:
42
diff
changeset
|
15 |
self.top.add_handler('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
|
16 |
#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
|
17 |
|
45
43b2279b06e1
Clean up Emitter class, simplify event handling. Fix Container.focusnext() method. Add events test (handler auto-registration, order).
Radek Brich <radek.brich@devl.cz>
parents:
42
diff
changeset
|
18 |
self._row_num = 0 |
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() |
63
2a0e04091898
Rework MenuBar. Add MenuButton. Add mouse event cascading to floaters.
Radek Brich <radek.brich@devl.cz>
parents:
62
diff
changeset
|
20 |
self.buildrow(spacing=1) |
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
|
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): |
62
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
45
diff
changeset
|
29 |
hbox = HorizontalLayout(homogeneous=homogeneous, spacing=spacing) |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
45
diff
changeset
|
30 |
hbox.resize(h=2) |
45
43b2279b06e1
Clean up Emitter class, simplify event handling. Fix Container.focusnext() method. Add events test (handler auto-registration, order).
Radek Brich <radek.brich@devl.cz>
parents:
42
diff
changeset
|
31 |
self._row_num += 1 |
43b2279b06e1
Clean up Emitter class, simplify event handling. Fix Container.focusnext() method. Add events test (handler auto-registration, order).
Radek Brich <radek.brich@devl.cz>
parents:
42
diff
changeset
|
32 |
hbox.name = 'hbox' + str(self._row_num) |
43b2279b06e1
Clean up Emitter class, simplify event handling. Fix Container.focusnext() method. Add events test (handler auto-registration, order).
Radek Brich <radek.brich@devl.cz>
parents:
42
diff
changeset
|
33 |
self.top.add(hbox) |
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
|
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) |
45
43b2279b06e1
Clean up Emitter class, simplify event handling. Fix Container.focusnext() method. Add events test (handler auto-registration, order).
Radek Brich <radek.brich@devl.cz>
parents:
42
diff
changeset
|
36 |
hbox.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() |
45
43b2279b06e1
Clean up Emitter class, simplify event handling. Fix Container.focusnext() method. Add events test (handler auto-registration, order).
Radek Brich <radek.brich@devl.cz>
parents:
42
diff
changeset
|
41 |
return True |
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
|
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 |
|
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 |
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
|
45 |
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
|
46 |
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
|
47 |