Author: reinhard
Date: 2007-04-07 12:36:30 -0500 (Sat, 07 Apr 2007)
New Revision: 9464
Modified:
trunk/gnue-forms/src/GFObjects/GFEntry.py
trunk/gnue-forms/src/GFObjects/GFHBox.py
trunk/gnue-forms/src/GFObjects/GFObj.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/vbox.py
Log:
Put label to the left of hbox if it is a member of a vbox and contains only
label-less single-cell children. This makes it possible to, for example, put a
button besides an entry.
Modified: trunk/gnue-forms/src/GFObjects/GFEntry.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFEntry.py 2007-04-07 15:21:52 UTC (rev 9463)
+++ trunk/gnue-forms/src/GFObjects/GFEntry.py 2007-04-07 17:36:30 UTC (rev 9464)
@@ -43,7 +43,7 @@
# Default attributes (these may be replaced by parser)
self.style = "default"
- self.label = ""
+ self.label = None
# Trigger exposure
self._validTriggers = {
@@ -113,6 +113,18 @@
return self.navigable and self._block.navigable and not self.hidden
+
+ # -------------------------------------------------------------------------
+ # Indicate whether this widget makes use of the separate label column
+ # -------------------------------------------------------------------------
+
+ def __get_has_label(self):
+
+ return (self.label is not None and self.style != 'checkbox')
+
+ has_label = property(__get_has_label)
+
+
# =========================================================================
# Trigger functions
# =========================================================================
Modified: trunk/gnue-forms/src/GFObjects/GFHBox.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFHBox.py 2007-04-07 15:21:52 UTC (rev 9463)
+++ trunk/gnue-forms/src/GFObjects/GFHBox.py 2007-04-07 17:36:30 UTC (rev 9464)
@@ -25,6 +25,7 @@
"""
from GFContainer import GFContainer
+from GFVBox import GFVBox
__all__ = ['GFHBox']
@@ -49,3 +50,23 @@
GFContainer.__init__(self, parent, "GFHBox")
+ # -------------------------------------------------------------------------
+ # Indicate whether this widget makes use of the separate label column
+ # -------------------------------------------------------------------------
+
+ def __get_has_label(self):
+
+ if not isinstance(self.getParent(), GFVBox):
+ return False
+
+ # If any of our children is a VBox or uses a label, we draw a box
+ # around ourselves. Otherwise, use the label column of the containing
+ # box.
+ for child in self._children:
+ if isinstance(child, GFVBox) or isinstance(child, GFHBox):
+ return False
+ if hasattr(child, 'has_label') and child.has_label:
+ return False
+ return True
+
+ has_label = property(__get_has_label)
Modified: trunk/gnue-forms/src/GFObjects/GFObj.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/GFObj.py 2007-04-07 15:21:52 UTC (rev 9463)
+++ trunk/gnue-forms/src/GFObjects/GFObj.py 2007-04-07 17:36:30 UTC (rev 9464)
@@ -224,3 +224,14 @@
"""
self._form = self.findParentOfType('GFForm')
+
+
+ # -------------------------------------------------------------------------
+ # Indicate whether this widget makes use of the separate label column
+ # -------------------------------------------------------------------------
+
+ def __get_has_label(self):
+
+ return False
+
+ has_label = property(__get_has_label)
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py 2007-04-07 15:21:52 UTC (rev 9463)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/_base.py 2007-04-07 17:36:30 UTC (rev 9464)
@@ -341,7 +341,7 @@
# If a label is requested for the box, we have to wrap the container
# with a StaticBoxSizer.
- if self._gfObject.label is not None:
+ if self._gfObject.label is not None and not self._gfObject.has_label:
box_title = wx.StaticBox(self._container, -1, self._gfObject.label)
box = wx.StaticBoxSizer(box_title, wx.VERTICAL)
# Border inside the box is 6 pixel according to GNOME Human
@@ -355,6 +355,8 @@
# Human Interface Guidlines.
border = 6
else:
+ if self._gfObject.label is not None:
+ self.label = wx.StaticText(parent, -1, self._gfObject.label)
add = self._sizer
# "Invisible" boxes don't need any border.
border = 0
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/vbox.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/vbox.py 2007-04-07 15:21:52 UTC (rev 9463)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/vbox.py 2007-04-07 17:36:30 UTC (rev 9464)
@@ -60,9 +60,6 @@
span = (1, 1)
add = False
- both = isinstance(ui_widget, (UIVBox, hbox.UIHBox, grid.UIGrid)) or \
- isinstance (ui_widget.widget, wx.CheckBox)
-
if ui_widget.label:
add = True
flags = wx.ALIGN_CENTER_VERTICAL
@@ -78,7 +75,7 @@
else:
item = ui_widget.widget
- if both and not ui_widget.label:
+ if not ui_widget.label:
pos = (self.last_item, 0)
span = (1, 2)
else:
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.