By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,783 Members | 1,286 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,783 IT Pros & Developers. It's quick & easy.

wxPython: GridBagSizer, EXPAND, and HtmlListBox

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.