2.5 sizers, tooltips, odd increase in height

Hello,

I recently upgraded wxPython to 2.5.5.1 (from 2.4.x) on both my
Windows and Linux dev machines and found that my application now has
odd sizer related problems on the Windows side.

It is kind of hard to describe - each call to sizer.Add() creates a
cell that is taller than the previous, so by the time I've added the
last one, the height of that sizer row is many window heights.

A screenshot , to better illustrate is here:

<http://axentra.net/www/hellfroze/sizer.png>

This only occurs under Windows; the Linux version looks fine. The
relevant code snippet is below.

I've read about the changes made to sizers going from 2.4->2.5;
however, no amount of fiddling would fix the Windows problem. In
particular, changing window.SetSize to window.SetMinSize seemed to fix
the sizing, but the label would no longer display.

If I dispense with the added "window", and directly add the StaticText
to the sizer, then the display is correct. However, my tooltips no
longer work!

Any help appreciated,
-Harry

        #-- Create a 2 col grid for keyword=>value pairs. The first column
        #-- contains the label, the 2nd the actual control for inputing that
        #-- keyword's values
        gs = wx.FlexGridSizer(len(keywords)+1,2,5,10) # rows,col,vgap,hgap
        # +1 for padding...
        gs.Add(wx.Size(-1,5))
        gs.Add(wx.Size(-1,5))

        for keyword in keywords:

            #-- The label cell. wxStaticText doesn't do tooltips, so box it
            #-- in a wxWindow. This may be a hack :stuck_out_tongue:
            help = "%s\n Default: %s\n Type: %s" % (
                K.GetHelp(keyword),
                K.GetDefault(keyword),
                K.GetType(keyword))
            window = wx.Window(self, -1, style=wx.ALIGN_RIGHT)
            window.SetToolTip(wx.ToolTip(help))

            label = wx.StaticText(window,-1,keyword+":", style=wx.ALIGN_RIGHT)
            if K.IsRequired(keyword):
                label.SetForegroundColour("#ff0000")
            window.SetSize(label.GetSize())
            gs.Add(window, 1, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
             ...

Windows: wxPython2.5-unicode-2.5.5.1-py2.3
Linux: wxPython2.5-gtk2-unicode-2.5.5.1-1_py2.3

h3 wrote:

I've read about the changes made to sizers going from 2.4->2.5;
however, no amount of fiddling would fix the Windows problem. In
particular, changing window.SetSize to window.SetMinSize seemed to fix
the sizing, but the label would no longer display.

I'm not sure why SetMinSize would cause a problem like this, there should be no effect on the statictext... Does it make any difference if you use window.SetMinSize(label.GetBestSize()) ?

Another thing to try is giving window a sizer with just the statictext in it, and then don't call SetMinSize.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Both of the above resulted in the same thing: the spacing on the
labels are correct, however, the label does not appear. Screenshot
here:

<http://axentra.net/www/hellfroze/sizer2.png&gt;

The modified code (additional sizer added to window):

            window.SetToolTip(wx.ToolTip(help))
            label = wx.StaticText(window,-1,keyword+":", style=wx.ALIGN_RIGHT)
            if K.IsRequired(keyword):
                label.SetForegroundColour("#ff0000")
            hack = wx.BoxSizer(wx.VERTICAL)
            hack.Add(label,0);
            window.SetSizer(hack)
            gs.Add(window, 1, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)

Does this set off any light bulbs?

Thanks,
Harry

···

On 6/3/05, Robin Dunn <robin@alldunn.com> wrote:

I'm not sure why SetMinSize would cause a problem like this, there
should be no effect on the statictext... Does it make any difference if
you use window.SetMinSize(label.GetBestSize()) ?

Another thing to try is giving window a sizer with just the statictext
in it, and then don't call SetMinSize.

h3 wrote:

···

On 6/3/05, Robin Dunn <robin@alldunn.com> wrote:

I'm not sure why SetMinSize would cause a problem like this, there
should be no effect on the statictext... Does it make any difference if
you use window.SetMinSize(label.GetBestSize()) ?

Another thing to try is giving window a sizer with just the statictext
in it, and then don't call SetMinSize.

Both of the above resulted in the same thing: the spacing on the
labels are correct, however, the label does not appear. Screenshot
here:

<http://axentra.net/www/hellfroze/sizer2.png&gt;

The modified code (additional sizer added to window):

            window.SetToolTip(wx.ToolTip(help))
            label = wx.StaticText(window,-1,keyword+":", style=wx.ALIGN_RIGHT)
            if K.IsRequired(keyword):
                label.SetForegroundColour("#ff0000")
            hack = wx.BoxSizer(wx.VERTICAL)
            hack.Add(label,0);
            window.SetSizer(hack)
            gs.Add(window, 1, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)

Does this set off any light bulbs?

Sorry, it doesn't. Please make a small sample app that shows the problem.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!