tuikit/application.py
author Radek Brich <radek.brich@devl.cz>
Tue, 08 Jan 2013 23:59:55 +0100
changeset 59 729fcdfe6b57
parent 57 911927edbdde
child 62 2f61931520c9
permissions -rw-r--r--
Cleanup timeouts.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
# -*- coding: utf-8 -*-
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     3
import logging
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
import time
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
18
e6c3a5ee91aa Eliminate relative imports.
Radek Brich <radek.brich@devl.cz>
parents: 17
diff changeset
     6
from tuikit.container import Container
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
59
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
     9
class Timer:
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    10
    def __init__(self):
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    11
        self.timeouts = []
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    12
        self.timelast = None
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    13
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    14
    def add_timeout(self, delay, callback):
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    15
        """Register callback to be called after delay seconds.
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    16
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    17
        delay -- in seconds, float
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    18
        callback -- function to be called with no parameters
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    19
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    20
        """
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    21
        if not len(self.timeouts):
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    22
            self.timelast = time.time()
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    23
        self.timeouts += [[delay, callback]]
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    24
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    25
    def remove_timeout(self, callback):
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    26
        """Unregister callback previously registered with add_timeout."""
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    27
        for timeout in self.timeouts[:]:
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    28
            if timeout[1] == callback:
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    29
                self.timeouts.remove(timeout)
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    30
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    31
    def has_timeout(self):
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    32
        return len(self.timeouts) > 0
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    33
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    34
    def nearest_timeout(self):
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    35
        if not self.has_timeout():
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    36
            return None
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    37
        return min(self.timeouts)[0]
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    38
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    39
    def process_timeouts(self):
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    40
        if not self.has_timeout():
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    41
            return
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    42
        now = time.time()
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    43
        lasted = now - self.timelast
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    44
        self.timelast = now
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    45
        for timeout in self.timeouts[:]:
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    46
            adjusted_delay = timeout[0] - lasted
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    47
            if adjusted_delay <= 0.0:
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    48
                timeout[1]()
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    49
                self.timeouts.remove(timeout)
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    50
            else:
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    51
                timeout[0] = adjusted_delay
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    52
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    53
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    54
class TopWindow(Container):
32
088b92ffb119 Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents: 30
diff changeset
    55
13
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 11
diff changeset
    56
    '''Top window of an application. Covers entire screen.'''
32
088b92ffb119 Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents: 30
diff changeset
    57
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    58
    def __init__(self):
13
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 11
diff changeset
    59
        '''Create top window.'''
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    60
        Container.__init__(self)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    61
        self.top = self
59
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
    62
        self.timer = Timer()
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    63
46
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents: 36
diff changeset
    64
    def draw(self, driver, x=0, y=0):
36
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    65
        """Draw the top window and its children.
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    66
36
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    67
        This is entry point for full screen redraw.
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    68
caf927c3f10b Update docs.
Radek Brich <radek.brich@devl.cz>
parents: 34
diff changeset
    69
        """
46
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents: 36
diff changeset
    70
        driver.erase()
2b43a7f38c34 Minor updates. Replace super() with direct class reference. Add demo_colors.
Radek Brich <radek.brich@devl.cz>
parents: 36
diff changeset
    71
        Container.draw(self, driver, x, y)
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    72
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    73
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    74
class Application:
32
088b92ffb119 Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents: 30
diff changeset
    75
13
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 11
diff changeset
    76
    '''Application class. Defines main loop.'''
32
088b92ffb119 Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents: 30
diff changeset
    77
49
1611c462c3e3 Update sdlterm: Optimize commit() - use two cell buffers, redraw only dirty cells, not everything. Fix keypress event, filter mousemove.
Radek Brich <radek.brich@devl.cz>
parents: 46
diff changeset
    78
    def __init__(self, driver = 'sdl'):
13
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 11
diff changeset
    79
        '''Create application.'''
32
088b92ffb119 Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents: 30
diff changeset
    80
23
4e72fd2a0e14 Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
    81
        self.top = TopWindow()
13
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 11
diff changeset
    82
        '''Top window.'''
32
088b92ffb119 Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents: 30
diff changeset
    83
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    84
        self.quit = False
32
088b92ffb119 Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents: 30
diff changeset
    85
29
c0cdef06fd16 Import only one driver from application.
Radek Brich <radek.brich@devl.cz>
parents: 24
diff changeset
    86
        self.driver = self.get_driver_instance(driver)
c0cdef06fd16 Import only one driver from application.
Radek Brich <radek.brich@devl.cz>
parents: 24
diff changeset
    87
        '''Driver class instance (render + input), e.g. DriverCurses.'''
32
088b92ffb119 Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents: 30
diff changeset
    88
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    89
        self.log = logging.getLogger('tuikit')
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    90
        self.log.setLevel(logging.DEBUG)
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    91
        handler = logging.FileHandler('./tuikit.log')
15
c55b4749e562 Add Pager.
Radek Brich <radek.brich@devl.cz>
parents: 13
diff changeset
    92
        formatter = logging.Formatter('%(asctime)s %(levelname)-5s %(message)s', '%y-%m-%d %H:%M:%S')
c55b4749e562 Add Pager.
Radek Brich <radek.brich@devl.cz>
parents: 13
diff changeset
    93
        handler.setFormatter(formatter)
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    94
        self.log.addHandler(handler)
15
c55b4749e562 Add Pager.
Radek Brich <radek.brich@devl.cz>
parents: 13
diff changeset
    95
        self.log.info('=== start ===')
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    96
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    97
    def start(self):
13
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 11
diff changeset
    98
        '''Start application. Runs main loop.'''
23
4e72fd2a0e14 Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
    99
        self.driver.start(self.mainloop)
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   100
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   101
    def terminate(self):
13
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 11
diff changeset
   102
        '''Terminate application.'''
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   103
        self.quit = True
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   104
23
4e72fd2a0e14 Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
   105
    def mainloop(self):
13
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 11
diff changeset
   106
        '''The main loop.'''
7
d4a291b31cbb New color management - named colors.
Radek Brich <radek.brich@devl.cz>
parents: 1
diff changeset
   107
        self.applytheme()
32
088b92ffb119 Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents: 30
diff changeset
   108
        self.top.size = self.driver.size  # link top widget size to screen size
34
e3beacd5e536 Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents: 32
diff changeset
   109
        self.top.emit('resize')
59
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
   110
        timer = self.top.timer
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   111
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   112
        while True:
23
4e72fd2a0e14 Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
   113
            self.top.draw(self.driver)
4e72fd2a0e14 Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
   114
            self.driver.commit()
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   115
59
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
   116
            timeout = timer.nearest_timeout()
24
b248ef500557 Add DriverPygame (incomplete). Move unicode graphics constants to UnicodeGraphics class. Move shared parts of drivers to Driver base class.
Radek Brich <radek.brich@devl.cz>
parents: 23
diff changeset
   117
            events = self.driver.getevents(timeout)
59
729fcdfe6b57 Cleanup timeouts.
Radek Brich <radek.brich@devl.cz>
parents: 57
diff changeset
   118
            timer.process_timeouts()
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   119
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   120
            for event in events:
24
b248ef500557 Add DriverPygame (incomplete). Move unicode graphics constants to UnicodeGraphics class. Move shared parts of drivers to Driver base class.
Radek Brich <radek.brich@devl.cz>
parents: 23
diff changeset
   121
                if event[0] == 'quit':
b248ef500557 Add DriverPygame (incomplete). Move unicode graphics constants to UnicodeGraphics class. Move shared parts of drivers to Driver base class.
Radek Brich <radek.brich@devl.cz>
parents: 23
diff changeset
   122
                    self.quit = True
b248ef500557 Add DriverPygame (incomplete). Move unicode graphics constants to UnicodeGraphics class. Move shared parts of drivers to Driver base class.
Radek Brich <radek.brich@devl.cz>
parents: 23
diff changeset
   123
                else:
b248ef500557 Add DriverPygame (incomplete). Move unicode graphics constants to UnicodeGraphics class. Move shared parts of drivers to Driver base class.
Radek Brich <radek.brich@devl.cz>
parents: 23
diff changeset
   124
                    self.top.emit(event[0], *event[1:])
0
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   125
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   126
            if self.quit:
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   127
                break
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
   128
7
d4a291b31cbb New color management - named colors.
Radek Brich <radek.brich@devl.cz>
parents: 1
diff changeset
   129
d4a291b31cbb New color management - named colors.
Radek Brich <radek.brich@devl.cz>
parents: 1
diff changeset
   130
    def applytheme(self):
52
50a1857557da Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents: 49
diff changeset
   131
        #TODO: allow custom colors:
50a1857557da Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents: 49
diff changeset
   132
        #    e.g. "blue (#2020FF) on black (#101010), underline"
50a1857557da Update SDL driver: Enlarge char, attr to 32 bits, 64 bits per terminal cell. Colors and attributes are complete, only blink does not work.
Radek Brich <radek.brich@devl.cz>
parents: 49
diff changeset
   133
        #    color in brackets is used when driver supports custom colors
23
4e72fd2a0e14 Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
   134
        driver = self.driver
4e72fd2a0e14 Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
   135
        driver.setcolor('normal',                  'white on black')
4e72fd2a0e14 Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
   136
        driver.setcolor('strong',                  'white on black, bold')
4e72fd2a0e14 Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
   137
        driver.setcolor('active',                  'black on cyan')
4e72fd2a0e14 Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
   138
        driver.setcolor('window:normal',           'white on blue')
4e72fd2a0e14 Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
   139
        driver.setcolor('window:controls',         'white on blue, bold')
4e72fd2a0e14 Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
   140
        driver.setcolor('window:controls-active',  'cyan on blue, bold')
4e72fd2a0e14 Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
   141
        driver.setcolor('button',                  'black on white')
4e72fd2a0e14 Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
   142
        driver.setcolor('button-active',           'black on cyan')
4e72fd2a0e14 Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
   143
        driver.setcolor('menu',                    'black on cyan')
4e72fd2a0e14 Rename BackendCurses to DriverCurses. Add DriverDummy - dummy driver for debugging purposes. Move clipping stack from driver to common.ClipStack class.
Radek Brich <radek.brich@devl.cz>
parents: 21
diff changeset
   144
        driver.setcolor('menu-active',             'white on cyan, bold')
30
05500124d7fb Add setup script. Add Checkbox widget + demo. Updates.
Radek Brich <radek.brich@devl.cz>
parents: 29
diff changeset
   145
        driver.setcolor('combo:normal',            'black on green')
13
19ebde2fd594 Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents: 11
diff changeset
   146
29
c0cdef06fd16 Import only one driver from application.
Radek Brich <radek.brich@devl.cz>
parents: 24
diff changeset
   147
c0cdef06fd16 Import only one driver from application.
Radek Brich <radek.brich@devl.cz>
parents: 24
diff changeset
   148
    def get_driver_instance(self, name):
c0cdef06fd16 Import only one driver from application.
Radek Brich <radek.brich@devl.cz>
parents: 24
diff changeset
   149
        module = __import__('tuikit.driver_' + name, fromlist=['driverclass'])
c0cdef06fd16 Import only one driver from application.
Radek Brich <radek.brich@devl.cz>
parents: 24
diff changeset
   150
        return module.driverclass()
c0cdef06fd16 Import only one driver from application.
Radek Brich <radek.brich@devl.cz>
parents: 24
diff changeset
   151