demos/demobase.py
author Radek Brich <radek.brich@devl.cz>
Wed, 03 Sep 2014 08:53:44 +0200
changeset 106 abcadb7e2ef1
parent 96 68c562e0eb1f
permissions -rw-r--r--
Use Point for mouse events, add them to Container and Widget.
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
# Path to root directory containing tuikit package
92
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
import sys
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     3
sys.path.append('..')
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
96
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
     5
# Set system locale (needed for ncurses)
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
     6
import locale
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
     7
locale.setlocale(locale.LC_ALL, '')
92
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
# Setup logging
96
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
    10
import logging
92
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
logger = logging.getLogger('tuikit')
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
logger.setLevel(logging.DEBUG)
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
handler = logging.FileHandler(filename='tuikit.log')
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
handler.setLevel(logging.DEBUG)
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
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
    16
handler.setFormatter(formatter)
b97c4e25ed6d Configure logging for demos.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
logger.addHandler(handler)
96
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
    18
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
    19
# 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
    20
# 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
    21
# 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
    22
import os
68c562e0eb1f Add TextBox, text editor demo. Update demobase.
Radek Brich <radek.brich@devl.cz>
parents: 92
diff changeset
    23
os.environ['ESCDELAY'] = '200'