set different initial and minimum dimensions for sizer item?

After some searching on the topic (and a quick review of Rappin &
Dunn, Chapter 11), I am stumped on this:

I would like to set an initial size for a grid that is larger than the
grid's minimum size. I would prefer that the initial size also be
smaller than the full size of the object. This would allow the user to
use more or less screen real-estate, depending on what they prefer,
but start the app with a good compromise. If I set the size for the
grid (either when I create it or using the sizer's SetItemMinSize
method) that is both the initial and minimum size. If I do not set a
size, the grid starts out fully expanded, but has no minimum.

Is there a simple way to do this?

Brian

For the archive, this was answered on wx-users. http://groups.google.com/group/wx-users/browse_frm/thread/458d09fc7b493198#

···

On 10/30/09 3:40 PM, bht wrote:

After some searching on the topic (and a quick review of Rappin&
Dunn, Chapter 11), I am stumped on this:

I would like to set an initial size for a grid that is larger than the
grid's minimum size. I would prefer that the initial size also be
smaller than the full size of the object. This would allow the user to
use more or less screen real-estate, depending on what they prefer,
but start the app with a good compromise. If I set the size for the
grid (either when I create it or using the sizer's SetItemMinSize
method) that is both the initial and minimum size. If I do not set a
size, the grid starts out fully expanded, but has no minimum.

Is there a simple way to do this?

--
Robin Dunn
Software Craftsman

(sorry, I did post to the wrong list initially).

In fact, the suggestion on wx-users did not work, at least not when
translated to wxpython. Here is a code fragment:

        self.grid = DragableGrid(self, log, self)
        self.table = self.grid.GetTable()
        mainSizer.Add(self.grid, 1, wx.EXPAND | wx.ALL, 0)
        #mainSizer.SetItemMinSize(self.grid, 400, 150)
        self.grid.SetSizeHints(400, 150)
        # this is supposed to set an initial size, but does not
        self.grid.SetSize(wx.Size(500, 300))

In the code above, the commented SetItemMinSize seems to do exactly
the same thing as SetSizeHints, but SetSize does not seem to have any
effect. I also tried moving the SetSize to be the last item in the
__init__ after sizer fit/layout calls, just in case that mattered.
(Tested on OSX10.4 and FC10.)

The suggestion on wx-users was to set the size of the frame such that it is larger than the min size needed, and then the contents of the frame (including the grid) would be laid out accordingly.

···

On 11/1/09 6:39 PM, bht wrote:

(sorry, I did post to the wrong list initially).

In fact, the suggestion on wx-users did not work, at least not when
translated to wxpython. Here is a code fragment:

         self.grid = DragableGrid(self, log, self)
         self.table = self.grid.GetTable()
         mainSizer.Add(self.grid, 1, wx.EXPAND | wx.ALL, 0)
         #mainSizer.SetItemMinSize(self.grid, 400, 150)
         self.grid.SetSizeHints(400, 150)
         # this is supposed to set an initial size, but does not
         self.grid.SetSize(wx.Size(500, 300))

In the code above, the commented SetItemMinSize seems to do exactly
the same thing as SetSizeHints, but SetSize does not seem to have any
effect. I also tried moving the SetSize to be the last item in the
__init__ after sizer fit/layout calls, just in case that mattered.

--
Robin Dunn
Software Craftsman

..set the size of the frame such that it
is larger than the min size needed, and then the contents of the frame
(including the grid) would be laid out accordingly.

Now I get it!

Indeed, adding

        (initX,initY) = self.GetSize()
        self.SetSize(wx.Size(1.5*initX,1.1*initY))

at the end of the frame creation does exactly what I want. Thanks very
much,

Brian