demo_colors.py
author Radek Brich <radek.brich@devl.cz>
Sat, 05 Jan 2013 00:37:11 +0100
changeset 46 2b43a7f38c34
child 52 50a1857557da
permissions -rwxr-xr-x
Minor updates. Replace super() with direct class reference. Add demo_colors.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
46
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
#!/usr/bin/env python3
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
# -*- coding: utf-8 -*-
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     3
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
import locale
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
locale.setlocale(locale.LC_ALL, '')
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     6
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
from tuikit import Application, Label, VerticalLayout
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
class MyApplication(Application):
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
    def __init__(self):
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
        Application.__init__(self)
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
        self.top.add_handler('keypress', self.on_top_keypress)
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
        for attr in ['blink', 'bold', 'dim', 'standout', 'underline']:
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
            label = Label(attr)
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
            label.color = 'test-' + attr
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
            self.top.add(label)
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    20
        self.top.layout = VerticalLayout()
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    21
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    22
    def on_top_keypress(self, ev):
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    23
        if ev.keyname == 'escape':
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    24
            self.terminate()
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    25
            return True
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    26
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    27
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    28
if __name__ == '__main__':
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    29
    app = MyApplication()
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    30
    app.start()
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    31