demo_colors.py
author Radek Brich <radek.brich@devl.cz>
Fri, 01 Feb 2013 09:34:15 +0100
changeset 75 2430c643838a
parent 70 db2eab0beb45
permissions -rwxr-xr-x
Clean up hints - add methods update_hint, hint_value to Widget. Split ScrollView into OffsetView and Scrolling components. Reimplement ScrollWindow using Scrolling component.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import locale
locale.setlocale(locale.LC_ALL, '')

from tuikit import Application, Window, Label, AnchorLayout, VerticalLayout


class MyApplication(Application):
    def __init__(self):
        Application.__init__(self, top_layout=AnchorLayout)
        self.top.add_handler('keypress', self.on_top_keypress)

        win = Window(inner_layout=VerticalLayout)
        win.resize(30,10)
        win.title = 'styles'

        for attr in ['blink', 'bold', 'standout', 'underline']:
            label = Label(attr)
            label.color = 'test-' + attr
            win.add(label)

        self.top.add(win)

    def apply_theme(self):
        Application.apply_theme(self)
        self.driver.defcolor('test-blink',              'cyan on blue, blink')
        self.driver.defcolor('test-bold',               'cyan on blue, bold')
        self.driver.defcolor('test-standout',           'cyan on blue, standout')
        self.driver.defcolor('test-underline',          'cyan on blue, underline')

    def on_top_keypress(self, ev):
        if ev.keyname == 'escape':
            self.terminate()
            return True


if __name__ == '__main__':
    app = MyApplication()
    app.start()