Author: reinhard
Date: 2007-04-09 16:51:28 -0500 (Mon, 09 Apr 2007)
New Revision: 9472
Modified:
trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/hbox.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/vbox.py
Log:
Fixed some growable/non-growable issues.
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py 2007-04-09 21:02:51 UTC (rev 9471)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py 2007-04-09 21:51:28 UTC (rev 9472)
@@ -298,7 +298,6 @@
_vertical_ = True
last_item = 0
_entry_pos = 0
- growable = True
# -------------------------------------------------------------------------
# Create the box widget
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/hbox.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/hbox.py 2007-04-09 21:02:51 UTC (rev 9471)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/hbox.py 2007-04-09 21:51:28 UTC (rev 9472)
@@ -69,17 +69,30 @@
span = (1, 1)
item = ui_widget.widget
- flags = wx.ALIGN_TOP | wx.EXPAND
+ if ui_widget.growable:
+ # For (vertically) growable widgets, let them expand.
+ flags = wx.EXPAND
+ elif self._gfObject.has_label:
+ # If this is a single-line hbox (with label to the left), align
+ # all widgets (vertically) centered, this looks better.
+ # We want to expand horizontally, but align vertically. Since
+ # wx.EXPAND makes the widget expand to both directions, we must
+ # introduce another sizer.
+ flags = wx.EXPAND
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ box.Add(item, 1, wx.ALIGN_CENTER)
+ item = box
+ else:
+ # Otherwise, align widgets on top.
+ flags = wx.EXPAND
+ box = wx.BoxSizer(wx.HORIZONTAL)
+ box.Add(item, 1, wx.ALIGN_TOP)
+ item = box
+
if isinstance(ui_widget, button.UIButton):
item = self.add_to_hbox(item, False)
- elif not ui_widget.growable:
- box = wx.BoxSizer(wx.VERTICAL)
- box.Add(item, 0, wx.EXPAND)
- box.Add((0,0))
- item = box
-
self._sizer.Add(item, pos, span, flags)
# Only columns having a stretch greater than zero require a growable
@@ -91,6 +104,11 @@
# self._sizer.AddGrowableCol(self.last_item, ui_widget.stretch)
self._sizer.AddGrowableCol(self.last_item)
+ # A hbox is only growable (vertically) if at least one of its members
+ # is growable.
+ if ui_widget.growable:
+ self.growable = True
+
self.last_item += add
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/vbox.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/vbox.py 2007-04-09 21:02:51 UTC (rev 9471)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/vbox.py 2007-04-09 21:51:28 UTC (rev 9472)
@@ -41,8 +41,6 @@
Implementation of the vbox tag
"""
- growable = True
-
# -------------------------------------------------------------------------
# Add an UI widget to the VBox container
# -------------------------------------------------------------------------
@@ -91,6 +89,11 @@
# self._sizer.AddGrowableRow(self.last_item, ui_widget.stretch)
self._sizer.AddGrowableRow(self.last_item)
+ # A vbox is only growable (vertically) if at least one of its members
+ # is growable.
+ if ui_widget.growable:
+ self.growable = True
+
self.last_item += add
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.