tuikit/label.py
author Radek Brich <radek.brich@devl.cz>
Sat, 05 Jan 2013 00:37:11 +0100
changeset 46 2b43a7f38c34
parent 45 43b2279b06e1
child 62 2f61931520c9
permissions -rw-r--r--
Minor updates. Replace super() with direct class reference. Add demo_colors.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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=''):
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
        Widget.__init__(self, len(label), 1)
d4ee152d7d07 Test for GridLayout. New Label widget.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
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