Handle curses resize event.
authorRadek Brich <radek.brich@devl.cz>
Fri, 07 Oct 2011 10:57:12 +0200
changeset 17 5be7cc43402e
parent 16 8791a7da6835
child 18 e6c3a5ee91aa
Handle curses resize event.
tuikit/application.py
tuikit/backend_curses.py
tuikit/layout.py
tuikit/pager.py
--- a/tuikit/application.py	Tue Oct 04 22:51:12 2011 +0200
+++ b/tuikit/application.py	Fri Oct 07 10:57:12 2011 +0200
@@ -126,6 +126,8 @@
                 self.top.process_timeout()
 
             for event in events:
+                if event[0] == 'resize':
+                    self.top.width, self.top.height = self.screen.width, self.screen.height
                 self.top.emit(event[0], *event[1:])
 
             if self.quit:
--- a/tuikit/backend_curses.py	Tue Oct 04 22:51:12 2011 +0200
+++ b/tuikit/backend_curses.py	Fri Oct 07 10:57:12 2011 +0200
@@ -390,6 +390,10 @@
 
             if c == curses.KEY_MOUSE:
                 res += self.process_mouse()
+            
+            elif c == curses.KEY_RESIZE:
+                self.height, self.width = self.screen.getmaxyx()
+                res.append(('resize',))
 
             elif curses.ascii.isctrl(c):
                 self.inputqueue_unget(c)
--- a/tuikit/layout.py	Tue Oct 04 22:51:12 2011 +0200
+++ b/tuikit/layout.py	Fri Oct 07 10:57:12 2011 +0200
@@ -25,7 +25,7 @@
 
 
 class LinearLayout(Layout):
-    def __init__(self, homogeneous=True, spacing=0):
+    def __init__(self, homogeneous=False, spacing=0):
         self.homogeneous = homogeneous
         self.spacing = spacing
 
--- a/tuikit/pager.py	Tue Oct 04 22:51:12 2011 +0200
+++ b/tuikit/pager.py	Fri Oct 07 10:57:12 2011 +0200
@@ -19,12 +19,13 @@
         self.layout(vert)
         
         self.buttons = Container(20, 1)
+        self.buttons.sizereq.h = 1
         Container.add(self, self.buttons)
-        horz = HorizontalLayout()
+        horz = HorizontalLayout(homogeneous=True, spacing=1)
         self.buttons.layout(horz)
                 
     def add(self, widget, **kw):
-        Container.add(self, widget, **kw)
+        Container.add(self, widget, expand=True, fill=True)
         
         if self.selected is None:
             self.selected = widget
@@ -34,7 +35,7 @@
         
         btn = Button(kw['title'])
         btn.connect('click', lambda: self.select(widget))
-        self.buttons.add(btn)
+        self.buttons.add(btn, fill=True)
 
     def select(self, child):
         log = logging.getLogger('tuikit')