Minor updates. Replace super() with direct class reference. Add demo_colors.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demo_colors.py Sat Jan 05 00:37:11 2013 +0100
@@ -0,0 +1,31 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import locale
+locale.setlocale(locale.LC_ALL, '')
+
+from tuikit import Application, Label, VerticalLayout
+
+
+class MyApplication(Application):
+ def __init__(self):
+ Application.__init__(self)
+ self.top.add_handler('keypress', self.on_top_keypress)
+
+ for attr in ['blink', 'bold', 'dim', 'standout', 'underline']:
+ label = Label(attr)
+ label.color = 'test-' + attr
+ self.top.add(label)
+
+ self.top.layout = VerticalLayout()
+
+ def on_top_keypress(self, ev):
+ if ev.keyname == 'escape':
+ self.terminate()
+ return True
+
+
+if __name__ == '__main__':
+ app = MyApplication()
+ app.start()
+
--- a/tests/events.py Fri Jan 04 00:13:59 2013 +0100
+++ b/tests/events.py Sat Jan 05 00:37:11 2013 +0100
@@ -21,7 +21,7 @@
class B(A):
def __init__(self):
- super().__init__()
+ A.__init__(self)
def on_keypress(self, ev):
"""B"""
@@ -35,7 +35,7 @@
class C(B):
def __init__(self):
- super().__init__()
+ B.__init__(self)
def on_keypress(ev):
--- a/tuikit/application.py Fri Jan 04 00:13:59 2013 +0100
+++ b/tuikit/application.py Sat Jan 05 00:37:11 2013 +0100
@@ -20,14 +20,14 @@
self.timeout = []
self.timelast = None
- def draw(self, screen, x=0, y=0):
+ def draw(self, driver, x=0, y=0):
"""Draw the top window and its children.
This is entry point for full screen redraw.
"""
- screen.erase()
- super().draw(screen, x, y)
+ driver.erase()
+ Container.draw(self, driver, x, y)
def add_timeout(self, s, func):
if not len(self.timeout):
@@ -137,6 +137,12 @@
driver.setcolor('menu-active', 'white on cyan, bold')
driver.setcolor('combo:normal', 'black on green')
+ driver.setcolor('test-blink', 'cyan on blue, blink')
+ driver.setcolor('test-bold', 'cyan on blue, bold')
+ driver.setcolor('test-dim', 'cyan on blue, dim')
+ driver.setcolor('test-standout', 'cyan on blue, standout')
+ driver.setcolor('test-underline', 'cyan on blue, underline')
+
def get_driver_instance(self, name):
module = __import__('tuikit.driver_' + name, fromlist=['driverclass'])
--- a/tuikit/combobox.py Fri Jan 04 00:13:59 2013 +0100
+++ b/tuikit/combobox.py Sat Jan 05 00:37:11 2013 +0100
@@ -30,7 +30,7 @@
self._menu.allow_layout = False
def _set_top(self, value):
- super()._set_top(value)
+ Container._set_top(self, value)
self.top.add(self._menu)
def _on_btn_click(self, ev):
--- a/tuikit/container.py Fri Jan 04 00:13:59 2013 +0100
+++ b/tuikit/container.py Sat Jan 05 00:37:11 2013 +0100
@@ -110,15 +110,15 @@
if self.colorprefix:
driver.pushcolorprefix(self.colorprefix)
- super().draw(driver, x, y)
+ Widget.draw(self, driver, x, y)
- for child in [x for x in self.children if not x.allow_layout]:
+ for child in [ch for ch in self.children if not ch.allow_layout]:
child.draw(driver, x + child.x, y + child.y)
l, t, r, b = self.borders
driver.clipstack.push(x+l, y+t, self.width-l-r, self.height-t-b)
- for child in [x for x in self.children if x.allow_layout]:
+ for child in [ch for ch in self.children if ch.allow_layout]:
child.draw(driver,
x + self.offset.x + child.x,
y + self.offset.y + child.y)
--- a/tuikit/driver_curses.py Fri Jan 04 00:13:59 2013 +0100
+++ b/tuikit/driver_curses.py Sat Jan 05 00:37:11 2013 +0100
@@ -61,7 +61,7 @@
'blink' : curses.A_BLINK,
'bold' : curses.A_BOLD,
'dim' : curses.A_DIM,
- 'standout' : curses.A_STANDOUT,
+ 'standout' : curses.A_STANDOUT, # inverse bg/fg
'underline' : curses.A_UNDERLINE,
}
--- a/tuikit/driver_pygame.py Fri Jan 04 00:13:59 2013 +0100
+++ b/tuikit/driver_pygame.py Sat Jan 05 00:37:11 2013 +0100
@@ -69,8 +69,6 @@
for x in range(self.w):
fgcolor, bgcolor, flags = self.attrs[pos]
c = self.chars[pos]
- if c == ' ':
- c = None
self.render_char(surface, x, y, c,
fgcolor, bgcolor, flags)
pos += 1
@@ -89,7 +87,7 @@
if bgcolor != self.default_attr[1]:
screen.fill(bgcolor, pygame.Rect(dest.x, dest.y, self.charsize.w, self.charsize.h))
- if not c:
+ if c == ' ':
return
# choose font
--- a/tuikit/events.py Fri Jan 04 00:13:59 2013 +0100
+++ b/tuikit/events.py Sat Jan 05 00:37:11 2013 +0100
@@ -22,7 +22,7 @@
class DrawEvent(Event):
def __init__(self, driver, x, y):
- super().__init__()
+ Event.__init__(self)
self.driver = driver
self.x = x
self.y = y
@@ -33,7 +33,7 @@
class FocusEvent(Event):
def __init__(self, old=None, new=None):
- super().__init__()
+ Event.__init__(self)
#: Former focused widget.
self.old = old
#: Current focused widget.
@@ -45,7 +45,7 @@
class KeyboardEvent(Event):
def __init__(self, keyname, char):
- super().__init__()
+ Event.__init__(self)
self.keyname = keyname
self.char = char
@@ -55,7 +55,7 @@
class MouseEvent(Event):
def __init__(self, x=0, y=0, button=0):
- super().__init__()
+ Event.__init__(self)
self.x = x # global coordinates
self.y = y
self.wx = x # local widget coordinates
--- a/tuikit/label.py Fri Jan 04 00:13:59 2013 +0100
+++ b/tuikit/label.py Sat Jan 05 00:37:11 2013 +0100
@@ -8,9 +8,10 @@
Widget.__init__(self, len(label), 1)
self.label = label
+ self.color = 'normal'
def on_draw(self, ev):
- ev.driver.pushcolor('normal')
+ ev.driver.pushcolor(self.color)
ev.driver.puts(ev.x, ev.y, self.label)
ev.driver.popcolor()
--- a/tuikit/layout.py Fri Jan 04 00:13:59 2013 +0100
+++ b/tuikit/layout.py Sat Jan 05 00:37:11 2013 +0100
@@ -40,7 +40,7 @@
class LinearLayout(Layout):
def __init__(self, homogeneous=False, spacing=0):
- super().__init__()
+ Layout.__init__(self)
self.homogeneous = homogeneous
self.spacing = spacing
@@ -109,7 +109,7 @@
class GridLayout(Layout):
def __init__(self, numcols=2):
- super().__init__()
+ Layout.__init__(self)
self.numcols = numcols
--- a/tuikit/pager.py Fri Jan 04 00:13:59 2013 +0100
+++ b/tuikit/pager.py Sat Jan 05 00:37:11 2013 +0100
@@ -29,10 +29,10 @@
self.buttons = Container(20, 1)
self.buttons.sizereq.h = 1
self.buttons.layout = HorizontalLayout(homogeneous=True, spacing=1)
- super().add(self.buttons)
+ Container.add(self, self.buttons)
def add(self, widget, **kw):
- super().add(widget, expand=True, fill=True)
+ Container.add(self, widget, expand=True, fill=True)
if self.selected is None:
self.selected = widget
--- a/tuikit/scrollview.py Fri Jan 04 00:13:59 2013 +0100
+++ b/tuikit/scrollview.py Sat Jan 05 00:37:11 2013 +0100
@@ -21,7 +21,7 @@
self.add(self.vscroll)
def add(self, widget, **kwargs):
- super().add(widget, **kwargs)
+ Container.add(self, widget, **kwargs)
if widget != self.vscroll:
widget.add_handler('sizereq', self._on_child_sizereq)
widget.add_handler('spotmove', self._on_child_spotmove)