author | Radek Brich <radek.brich@devl.cz> |
Sat, 19 Jan 2013 13:05:21 +0100 | |
changeset 63 | 2a0e04091898 |
parent 62 | 2f61931520c9 |
permissions | -rw-r--r-- |
6
d4ee152d7d07
Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
1 |
# -*- coding: utf-8 -*- |
d4ee152d7d07
Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
2 |
|
18
e6c3a5ee91aa
Eliminate relative imports.
Radek Brich <radek.brich@devl.cz>
parents:
7
diff
changeset
|
3 |
from tuikit.widget import Widget |
6
d4ee152d7d07
Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
4 |
|
d4ee152d7d07
Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
5 |
|
d4ee152d7d07
Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
6 |
class Label(Widget): |
d4ee152d7d07
Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
7 |
def __init__(self, label=''): |
62
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
46
diff
changeset
|
8 |
Widget.__init__(self) |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
46
diff
changeset
|
9 |
self._default_size.update(len(label), 1) |
6
d4ee152d7d07
Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
10 |
self.label = label |
46
2b43a7f38c34
Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
45
diff
changeset
|
11 |
self.color = 'normal' |
6
d4ee152d7d07
Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
12 |
|
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:
41
diff
changeset
|
13 |
def on_draw(self, ev): |
46
2b43a7f38c34
Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
45
diff
changeset
|
14 |
ev.driver.pushcolor(self.color) |
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:
40
diff
changeset
|
15 |
ev.driver.puts(ev.x, ev.y, self.label) |
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:
40
diff
changeset
|
16 |
ev.driver.popcolor() |
6
d4ee152d7d07
Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff
changeset
|
17 |