Change floatspin size after creation?

Hi all,
I'm using a floatspin control and once it it created, I can't get it
to change size. This is particularly awkward when combined with
wxGlade, because wxGlade generates code that creates it at its default
size and then attempts to change the size later with SetMinSize().

I've tried calling SetSize(), SetBestSize() and SetMinSize() on the
floatspin control itself. I've also tried messing around with the
underlying BoxSizer and text control but with no luck.

Any advice would be appreciated.

Thanks
Philip

http://wiki.wxpython.org/Widget_Inspection_Tool

http://wiki.wxpython.org/MakingSampleApps

···

On 11/17/09 3:42 PM, Philip Semanchuk wrote:

Hi all,
I'm using a floatspin control and once it it created, I can't get it
to change size. This is particularly awkward when combined with
wxGlade, because wxGlade generates code that creates it at its default
size and then attempts to change the size later with SetMinSize().

I've tried calling SetSize(), SetBestSize() and SetMinSize() on the
floatspin control itself. I've also tried messing around with the
underlying BoxSizer and text control but with no luck.

Any advice would be appreciated.

--
Robin Dunn
Software Craftsman

Thanks, Robin, I wasn't aware of the invaluable Widget Inspection Tool
and that gave me what I needed to solve my problem. Here's a sample
app that shows the non-resizing behavior.

It turns out that the control is being resized, but it isn't resizing
its child controls. I worked out a patch for the floatspin control and
I'll send it to the author today.

#!/usr/bin/env python

import wx
import wx.lib.inspection

from wx.lib.agw.floatspin import FloatSpin, EVT_FLOATSPIN, FS_LEFT,
FS_RIGHT, FS_CENTRE, FS_READONLY

class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.label_1 = wx.StaticText(self, -1, "Here is a float spin control")
        self.float_spin_1 = FloatSpin(self, -1, extrastyle=FS_LEFT)

        self.SetTitle("frame_1")
        sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_1.Add(self.label_1, 0, 0, 0)
        sizer_1.Add(self.float_spin_1, 1, wx.EXPAND, 0)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        self.Layout()

        wx.lib.inspection.InspectionTool().Show()

app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame_1 = MyFrame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
app.MainLoop()

···

On Thu, Nov 19, 2009 at 9:28 PM, Robin Dunn <robin@alldunn.com> wrote:

On 11/17/09 3:42 PM, Philip Semanchuk wrote:

Hi all,
I'm using a floatspin control and once it it created, I can't get it
to change size. This is particularly awkward when combined with
wxGlade, because wxGlade generates code that creates it at its default
size and then attempts to change the size later with SetMinSize().

I've tried calling SetSize(), SetBestSize() and SetMinSize() on the
floatspin control itself. I've also tried messing around with the
underlying BoxSizer and text control but with no luck.

Any advice would be appreciated.

http://wiki.wxpython.org/Widget_Inspection_Tool

This is a followup in case anyone else stumbles across this post while
looking for a solution to the same problem. This was partially fixed
in r62581 and completely fixed in r62920:
http://trac.wxwidgets.org/browser/wxPython/3rdParty/AGW/agw/floatspin.py?rev=62920

bye
Philip

···

On Fri, Nov 20, 2009 at 10:35 AM, Philip Semanchuk <nikitathespider@gmail.com> wrote:

On Thu, Nov 19, 2009 at 9:28 PM, Robin Dunn <robin@alldunn.com> wrote:

On 11/17/09 3:42 PM, Philip Semanchuk wrote:

Hi all,
I'm using a floatspin control and once it it created, I can't get it
to change size. This is particularly awkward when combined with
wxGlade, because wxGlade generates code that creates it at its default
size and then attempts to change the size later with SetMinSize().

I've tried calling SetSize(), SetBestSize() and SetMinSize() on the
floatspin control itself. I've also tried messing around with the
underlying BoxSizer and text control but with no luck.

Any advice would be appreciated.

http://wiki.wxpython.org/Widget_Inspection_Tool

Thanks, Robin, I wasn't aware of the invaluable Widget Inspection Tool
and that gave me what I needed to solve my problem. Here's a sample
app that shows the non-resizing behavior.

It turns out that the control is being resized, but it isn't resizing
its child controls. I worked out a patch for the floatspin control and
I'll send it to the author today.

#!/usr/bin/env python

import wx
import wx.lib.inspection

from wx.lib.agw.floatspin import FloatSpin, EVT_FLOATSPIN, FS_LEFT,
FS_RIGHT, FS_CENTRE, FS_READONLY

class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.label_1 = wx.StaticText(self, -1, "Here is a float spin control")
self.float_spin_1 = FloatSpin(self, -1, extrastyle=FS_LEFT)

   self\.SetTitle\(&quot;frame\_1&quot;\)
   sizer\_1 = wx\.BoxSizer\(wx\.HORIZONTAL\)
   sizer\_1\.Add\(self\.label\_1, 0, 0, 0\)
   sizer\_1\.Add\(self\.float\_spin\_1, 1, wx\.EXPAND, 0\)
   self\.SetSizer\(sizer\_1\)
   sizer\_1\.Fit\(self\)
   self\.Layout\(\)

   wx\.lib\.inspection\.InspectionTool\(\)\.Show\(\)

app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame_1 = MyFrame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
app.MainLoop()