How does one use a wx.StaticLine in GridBagSizer?
When I place one it expands to fill BOTH directions displaying a big gray block instead of a gray line.
Is this a bug?
Peter.
wx
2.6.3.2 on py2.4 on WinXP SP2
How does one use a wx.StaticLine in GridBagSizer?
When I place one it expands to fill BOTH directions displaying a big gray block instead of a gray line.
Is this a bug?
Peter.
wx
2.6.3.2 on py2.4 on WinXP SP2
Peter Damoc wrote:
How does one use a wx.StaticLine in GridBagSizer?
When I place one it expands to fill BOTH directions displaying a big gray block instead of a gray line.Is this a bug?
Not really, but it is something that I would like to change about the grid sizers, I'd like to have separate flags for horizontal and vertical expansion. In the meantime you can work around this by putting the static line in a box sizer and setting it to expand in only the single direction. Then when the GridBagSizer expands the box sizer in both directions the static line will expand in only the one.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
Thursday, July 20, 2006, 5:23:27 AM, Peter Damoc wrote:
How does one use a wx.StaticLine in GridBagSizer?
When I place one it expands to fill BOTH directions displaying a big gray
block instead of a gray line.
Horizontal wx.StaticLines are also expanded vertically and vertical
wx.StaticLines are also expanded horizontally. To work around this try
using the StaticLine class below instead.
Note that while this StaticLine expands only in the "right" way, it
somehow is displayed at the top of its sizer's cell. So it's probably
a good idea to give it some wx.TOP border when adding it to a sizer.
class StaticLine(wx.StaticLine):
def __init__(self, *args, **kwargs):
size = kwargs.get("size", wx.Size(100, 100))
style = kwargs.get("style", wx.LI_HORIZONTAL)
d = wx.StaticLine.GetDefaultSize()
if style & wx.LI_HORIZONTAL:
kwargs["size"] = (size[0], d)
elif style & wx.LI_VERTICAL:
kwargs["size"] = (d, size[1])
wx.StaticLine.__init__(self, *args, **kwargs)
self.Bind(wx.EVT_SIZE, self.OnSize)
def OnSize(self, evt):
d = wx.StaticLine.GetDefaultSize()
style = self.GetWindowStyleFlag()
size = wx.StaticLine.GetSize(self)
if style & wx.LI_HORIZONTAL:
size = (size.width, d)
elif style & wx.LI_VERTICAL:
size = (d, size.height)
wx.StaticLine.SetSize(self, size)
-- tacao
No bits were harmed during the making of this e-mail.