demos/base.py
author Radek Brich <radek.brich@devl.cz>
Sun, 22 Feb 2015 09:53:13 +0100
changeset 119 dd91747504dd
parent 117 8680c2333546
permissions -rw-r--r--
Redraw widgets on request. Add scrollbar demo.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
96
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
     1
# Set system locale (needed for ncurses)
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
     2
import locale
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
     3
locale.setlocale(locale.LC_ALL, '')
92
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
# Setup logging
96
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
     6
import logging
92
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
logger = logging.getLogger('tuikit')
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
logger.setLevel(logging.DEBUG)
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
handler = logging.FileHandler(filename='tuikit.log')
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
handler.setLevel(logging.DEBUG)
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s')
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
handler.setFormatter(formatter)
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
logger.addHandler(handler)
96
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
    14
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
    15
# Escape key code is also used for escape sequences. After escape code,
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
    16
# terminal waits for rest of sequence. This delay is 1 second by default.
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
    17
# Let's hope that our terminal is fast enough to handle the sequences in 200ms.
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
    18
import os
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
    19
os.environ['ESCDELAY'] = '200'
117
8680c2333546 Update FixedLayout. Add demo launcher.
Radek Brich <radek.brich@devl.cz>
parents: 96
diff changeset
    20
8680c2333546 Update FixedLayout. Add demo launcher.
Radek Brich <radek.brich@devl.cz>
parents: 96
diff changeset
    21
def setup():
8680c2333546 Update FixedLayout. Add demo launcher.
Radek Brich <radek.brich@devl.cz>
parents: 96
diff changeset
    22
    pass