Implementing minimal Frame size in Python.

Hi,
I'm trying to make sure that the Frame cannot be resized below some
size, the quirk compared to .MinSize is that I want to limit minimal
ClientSize. It seems there's no way to cancel EVT_SIZE event and just
setting a different size in EVT_SIZE handler results in flicker. I
also tried to find exactly how MinSize is implemented in wxWidgets,
but I can't find the relevant code. So if you can point me in right
direction, I'd be very grateful.

Once again, what I need is:
Determine if the resize event is valid based on resulting
Frame.ClientSize and let it go through or not.

Thanks for any help!

···

--
Best Regards,
Sergey Schetinin

http://s3bk.com/ -- S3 Backup
http://word-to-html.com/ -- Word to HTML Converter

Sergey Schetinin wrote:

Hi,
I'm trying to make sure that the Frame cannot be resized below some
size, the quirk compared to .MinSize is that I want to limit minimal
ClientSize. It seems there's no way to cancel EVT_SIZE event and just
setting a different size in EVT_SIZE handler results in flicker. I
also tried to find exactly how MinSize is implemented in wxWidgets,
but I can't find the relevant code. So if you can point me in right
direction, I'd be very grateful.

Once again, what I need is:
Determine if the resize event is valid based on resulting
Frame.ClientSize and let it go through or not.

Thanks for any help!

You just need to use the frame's SetSizeHints method:

# SetSizeHints(minW, minH, maxW, maxH)
myFrame.SetSizeHints(250,200,700,300)

Adjust as needed. That should do it for you.

Mike

You just need to use the frame's SetSizeHints method:

# SetSizeHints(minW, minH, maxW, maxH)
myFrame.SetSizeHints(250,200,700,300)

Adjust as needed. That should do it for you.

Thanks, but that works for Size, not ClientSize.
Is there a reliable cross-platform way to convert size <-> clientsize
for various controls? (without resizing them)

I would catch the OnSize event and the first time it is
called, calculate the difference between the two sizes,
then use that difference in my minimum-size calculation.

···

At 02:37 PM 10/27/2008, you wrote:

> You just need to use the frame's SetSizeHints method:
>
> # SetSizeHints(minW, minH, maxW, maxH)
> myFrame.SetSizeHints(250,200,700,300)
>
> Adjust as needed. That should do it for you.

Thanks, but that works for Size, not ClientSize.
Is there a reliable cross-platform way to convert size <-> clientsize
for various controls? (without resizing them)

Good idea! Works for me, thanks.

···

On Tue, Oct 28, 2008 at 00:28, Phil Mayes <olivebr@olivebr.com> wrote:

At 02:37 PM 10/27/2008, you wrote:

> You just need to use the frame's SetSizeHints method:
>
> # SetSizeHints(minW, minH, maxW, maxH)
> myFrame.SetSizeHints(250,200,700,300)
>
>
> Adjust as needed. That should do it for you.

Thanks, but that works for Size, not ClientSize.
Is there a reliable cross-platform way to convert size <-> clientsize
for various controls? (without resizing them)

I would catch the OnSize event and the first time it is
called, calculate the difference between the two sizes,
then use that difference in my minimum-size calculation.

--
Best Regards,
Sergey Schetinin

http://s3bk.com/ -- S3 Backup
http://word-to-html.com/ -- Word to HTML Converter

Sergey Schetinin <maluke <at> gmail.com> writes:

> You just need to use the frame's SetSizeHints method:
>
> # SetSizeHints(minW, minH, maxW, maxH)
> myFrame.SetSizeHints(250,200,700,300)
>
>
> Adjust as needed. That should do it for you.

Thanks, but that works for Size, not ClientSize.
Is there a reliable cross-platform way to convert size <-> clientsize
for various controls? (without resizing them)
_______________________________________________
wxpython-users mailing list
wxpython-users <at> lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

I'm not sure if this is exactly what you wish. wxWidgets is somehow missing a
function which could have been called SetClientSizeHints().

As a workaround, I'm using something like this. hsizer1 is a sizer instance and
self.parent refers to the main frame.

        #set a height, all ColWin have the same height.
        hsizer1.SetMinSize((-1, 300))

        #set the sizer
        self.SetSizerAndFit(hsizer1)
        #set the client size of the main frame
        self.parent.SetClientSize(hsizer1.GetSize())
        #get the size of the main frame
        r = self.parent.GetSize()
        #now setsizehints, lock the frame height
        self.parent.SetSizeHints(r[0], r[1], -1, r[1])

        #centering
        self.parent.CentreOnScreen()

If I recall correctly, there is an example in

http://spinecho.ze.cx/ > LearnSizers8.zip

Jean-Michel Fauth, Switzerland