# HG changeset patch # User Radek Brich # Date 1395865599 -3600 # Node ID b97c4e25ed6df146a51e5c17a4296b351ebb688c # Parent de80e140b0ec470128da9d0193a829024d40854d Configure logging for demos. diff -r de80e140b0ec -r b97c4e25ed6d .hgignore --- a/.hgignore Wed Mar 26 09:08:10 2014 +0100 +++ b/.hgignore Wed Mar 26 21:26:39 2014 +0100 @@ -1,7 +1,7 @@ .*~$ ^tuikit/.*\.pyc$ ^docs/_build -^tuikit\.log +tuikit\.log ^build ^sdlterm/build ^sdlterm/font diff -r de80e140b0ec -r b97c4e25ed6d demos/01_buffer.py --- a/demos/01_buffer.py Wed Mar 26 09:08:10 2014 +0100 +++ b/demos/01_buffer.py Wed Mar 26 21:26:39 2014 +0100 @@ -1,7 +1,6 @@ #!/usr/bin/env python3 -import sys -sys.path.append('..') +import demobase from tuikit.core.buffer import Buffer from tuikit.driver.driver import Driver diff -r de80e140b0ec -r b97c4e25ed6d demos/02_curses.py --- a/demos/02_curses.py Wed Mar 26 09:08:10 2014 +0100 +++ b/demos/02_curses.py Wed Mar 26 21:26:39 2014 +0100 @@ -1,7 +1,6 @@ #!/usr/bin/env python3 -import sys -sys.path.append('..') +import demobase from tuikit.core.buffer import Buffer from tuikit.driver.curses import CursesDriver diff -r de80e140b0ec -r b97c4e25ed6d demos/03_application.py --- a/demos/03_application.py Wed Mar 26 09:08:10 2014 +0100 +++ b/demos/03_application.py Wed Mar 26 21:26:39 2014 +0100 @@ -1,7 +1,6 @@ #!/usr/bin/env python3 -import sys -sys.path.append('..') +import demobase from tuikit.core.application import Application from tuikit.widgets.label import Label diff -r de80e140b0ec -r b97c4e25ed6d demos/demobase.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demos/demobase.py Wed Mar 26 21:26:39 2014 +0100 @@ -0,0 +1,13 @@ +import sys +sys.path.append('..') + +import logging + +# Setup logging +logger = logging.getLogger('tuikit') +logger.setLevel(logging.DEBUG) +handler = logging.FileHandler(filename='tuikit.log') +handler.setLevel(logging.DEBUG) +formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s') +handler.setFormatter(formatter) +logger.addHandler(handler) diff -r de80e140b0ec -r b97c4e25ed6d tuikit/core/application.py --- a/tuikit/core/application.py Wed Mar 26 09:08:10 2014 +0100 +++ b/tuikit/core/application.py Wed Mar 26 21:26:39 2014 +0100 @@ -16,7 +16,7 @@ """ def __init__(self, driver='curses'): - self.log = logging.getLogger('tuikit') + self.log = logging.getLogger(__name__) self.driver = None self.timer = Timer() self.window_manager = WindowManager(timer=self.timer) @@ -45,7 +45,7 @@ def start(self): """Start application. Runs main loop.""" - self.log.info('=== start ===') + self.log.info('=== Start ===') with self.driver: self.main_loop() @@ -71,5 +71,5 @@ self.window_manager.handle_event(event[0], *event[1:]) self._started = False - self.log.info('=== quit ===') + self.log.info('=== End ===') diff -r de80e140b0ec -r b97c4e25ed6d tuikit/core/container.py --- a/tuikit/core/container.py Wed Mar 26 09:08:10 2014 +0100 +++ b/tuikit/core/container.py Wed Mar 26 21:26:39 2014 +0100 @@ -24,10 +24,10 @@ def draw(self, buffer, x=0, y=0): """Draw child widgets.""" for child in self.children: - with buffer.clip(x, y, child.width, child.height): - child.draw(buffer, - x + child.x, - y + child.y) + cx = x + child.x + cy = y + child.y + with buffer.clip(cx, cy, child.width, child.height): + child.draw(buffer, cx, cy) def set_theme(self, theme): Widget.set_theme(self, theme) diff -r de80e140b0ec -r b97c4e25ed6d tuikit/core/widget.py --- a/tuikit/core/widget.py Wed Mar 26 09:08:10 2014 +0100 +++ b/tuikit/core/widget.py Wed Mar 26 21:26:39 2014 +0100 @@ -55,7 +55,7 @@ ## appearance ## - def draw(self, buffer, x=0, y=0): + def draw(self, buffer, x, y): pass def set_theme(self, theme):