469,579 Members | 1,111 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,579 developers. It's quick & easy.

wxPython: GridBagSizer, EXPAND, and HtmlListBox

I'm having some trouble using an HtmlListBox with a GridBagSizer. I'm
not sure how best to explain what's happening, but it seems that every
time my frame gets resized, the HtmlListBox grows taller, even when the
resize is only horizontal, or makes the frame smaller. I'm pretty new
to GUI layout and wxPython, so hopefully I'm doing something obviously
wrong. Here's a short runnable code sample showing my basic layout (I'm
using python 2.3.3 and wxPython 2.6 running on windows XP pro):

-----Start Code-----

import wx

class TestFrame(wx.Frame):
def __init__(self):
app = wx.PySimpleApp()
wx.Frame.__init__(self, None, -1)
p = wx.Panel(self, -1)
gbs = wx.GridBagSizer(5, 5)
gbs.Add(wx.Button(p, -1), (0, 0), span=(1, 2), flag=wx.EXPAND)
hlb = wx.HtmlListBox(p, -1)
gbs.Add(hlb, (1, 0), span=(4, 1), flag=wx.EXPAND)
gbs.Add(wx.Button(p, -1), (1, 1), flag=wx.EXPAND)
gbs.Add(wx.Button(p, -1), (2, 1), flag=wx.EXPAND)
gbs.Add(wx.Button(p, -1), (3, 1), flag=wx.EXPAND)
gbs.Add(wx.Button(p, -1), (4, 1), flag=wx.EXPAND)
gbs.AddGrowableRow(2)
gbs.AddGrowableCol(1)
p.SetSizerAndFit(gbs)
self.SetClientSize(p.GetSize())
self.Show(True)
wx.EVT_SIZE(hlb, self.onSize)
app.MainLoop()

def onSize(self, event):
print event.GetSize()

if __name__ == '__main__':
TestFrame()

-----End Code-----

If you run that and try to resize the window by dragging an edge, the
HtmlListBox just goes crazy and keeps getting bigger (try dragging the
right edge back and forth).

It does the same thing if I replace the HtmlListBox with a wx.Panel or
even a wx.Window, but not with a wx.ListBox, or wx.Button. The effect
I'm trying to accomplish is basically what you get if you sub in a
wx.ListBox, (but I need the HtmlListBox because I want to put a small
image next to the strings in the list).

Removing the wx.EXPAND flag on the HtmlListBox (at line 11) solves the
weird resizing, except that now the HtmlListBox doesn't fill the space
it needs to.

Does anyone know what's going on here, or how I can get this to work?

Jul 19 '05 #1
1 3302
Just an update if anyone runs across this through google. It appears
this was an issue fixed in 2.6.0.1 (or 2.6.1.0, I forget which
exactly). I was using 2.6.0.0.

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by plumpy321 | last post: by
1 post views Thread by ncf | last post: by
1 post views Thread by PeterG | last post: by
reply views Thread by KvS | last post: by
2 posts views Thread by SMALLp | last post: by
reply views Thread by Robin Dunn | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.