In the attached example.py script, how can I make the window adjust its size after the size of the sizer?
My initial attempt was to get the size of the sizer with GetSize() and then adjust the size of the window with SetSize() before the window is shown on line 8. But that won’t work as GetSize() on the sizer returns (0, 0) before it’s shown on line 8. Is it possible to get the size of the sizer before the window is shown?
More general, is there a best practice how to do automatic size adjustments in wxPython? I could of course just manually adjust the size. But across platforms and computers I rather have wxPython do that for me automatically than use hardcoded sizes.
The first line does what you are asking for and the second one prevents e.g. a dialog to be sized smaller then what it needs to show all its controls (using up their minimum space).
Werner
···
On 09/15/2011 05:45 AM, �ke Kullenberg wrote:
In the attached example.py script, how can I make the window adjust its size after the size of the sizer?
My initial attempt was to get the size of the sizer with GetSize() and then adjust the size of the window with SetSize() before the window is shown on line 8. But that won't work as GetSize() on the sizer returns (0, 0) before it's shown on line 8. Is it possible to get the size of the sizer before the window is shown?
More general, is there a best practice how to do automatic size adjustments in wxPython? I could of course just manually adjust the size. But across platforms and computers I rather have wxPython do that for me automatically than use hardcoded sizes.
That doesn't really work for me. If I put those two lines before
self.Show() the window is rendered extremely small, and if I put it
afterwards the window doesn't change size at all.
···
On Sep 15, 2:47 pm, werner <wbru...@free.fr> wrote:
On 09/15/2011 05:45 AM, ke Kullenberg wrote:
> In the attached example.py script, how can I make the window adjust
> its size after the size of the sizer?
> My initial attempt was to get the size of the sizer with GetSize() and
> then adjust the size of the window with SetSize() before the window is
> shown on line 8. But that won't work as GetSize() on the sizer returns
> (0, 0) before it's shown on line 8. Is it possible to get the size of
> the sizer before the window is shown?
> More general, is there a best practice how to do automatic size
> adjustments in wxPython? I could of course just manually adjust the
> size. But across platforms and computers I rather have wxPython do
> that for me automatically than use hardcoded sizes.
The first line does what you are asking for and the second one prevents
e.g. a dialog to be sized smaller then what it needs to show all its
controls (using up their minimum space).
On Sep 15, 2:47 pm, werner<wbru...@free.fr> wrote:
On 09/15/2011 05:45 AM, ke Kullenberg wrote:
In the attached example.py script, how can I make the window adjust
its size after the size of the sizer?
My initial attempt was to get the size of the sizer with GetSize() and
then adjust the size of the window with SetSize() before the window is
shown on line 8. But that won't work as GetSize() on the sizer returns
(0, 0) before it's shown on line 8. Is it possible to get the size of
the sizer before the window is shown?
More general, is there a best practice how to do automatic size
adjustments in wxPython? I could of course just manually adjust the
size. But across platforms and computers I rather have wxPython do
that for me automatically than use hardcoded sizes.
This is what I use.
self.Fit()
self.SetMinSize(self.GetSize())
The first line does what you are asking for and the second one prevents
e.g. a dialog to be sized smaller then what it needs to show all its
controls (using up their minimum space).
Werner
That doesn't really work for me. If I put those two lines before
self.Show() the window is rendered extremely small, and if I put it
afterwards the window doesn't change size at all.
On Sep 15, 5:37 pm, werner <wbru...@free.fr> wrote:
On 09/15/2011 10:29 AM, c00kiemonster wrote:
> On Sep 15, 2:47 pm, werner<wbru...@free.fr> wrote:
>> On 09/15/2011 05:45 AM, ke Kullenberg wrote:
>>> In the attached example.py script, how can I make the window adjust
>>> its size after the size of the sizer?
>>> My initial attempt was to get the size of the sizer with GetSize() and
>>> then adjust the size of the window with SetSize() before the window is
>>> shown on line 8. But that won't work as GetSize() on the sizer returns
>>> (0, 0) before it's shown on line 8. Is it possible to get the size of
>>> the sizer before the window is shown?
>>> More general, is there a best practice how to do automatic size
>>> adjustments in wxPython? I could of course just manually adjust the
>>> size. But across platforms and computers I rather have wxPython do
>>> that for me automatically than use hardcoded sizes.
>> This is what I use.
>> self.Fit()
>> self.SetMinSize(self.GetSize())
>> The first line does what you are asking for and the second one prevents
>> e.g. a dialog to be sized smaller then what it needs to show all its
>> controls (using up their minimum space).
>> Werner
> That doesn't really work for me. If I put those two lines before
> self.Show() the window is rendered extremely small, and if I put it
> afterwards the window doesn't change size at all.
Yeap, didn't notice that there was a panel in there which wasn't in a sizer.
Added a sizer to the frame and add the panel to that sizer and then it
works.
In addition, if you ever just need to get the min size required by a sizer without using something like Fit that changes window size, then you can use sizer.CalcMin().
···
On 9/15/11 2:37 AM, werner wrote:
On 09/15/2011 10:29 AM, c00kiemonster wrote:
On Sep 15, 2:47 pm, werner<wbru...@free.fr> wrote:
On 09/15/2011 05:45 AM, ke Kullenberg wrote:
In the attached example.py script, how can I make the window adjust
its size after the size of the sizer?
My initial attempt was to get the size of the sizer with GetSize() and
then adjust the size of the window with SetSize() before the window is
shown on line 8. But that won't work as GetSize() on the sizer returns
(0, 0) before it's shown on line 8. Is it possible to get the size of
the sizer before the window is shown?
More general, is there a best practice how to do automatic size
adjustments in wxPython? I could of course just manually adjust the
size. But across platforms and computers I rather have wxPython do
that for me automatically than use hardcoded sizes.
This is what I use.
self.Fit()
self.SetMinSize(self.GetSize())
The first line does what you are asking for and the second one prevents
e.g. a dialog to be sized smaller then what it needs to show all its
controls (using up their minimum space).
Werner
That doesn't really work for me. If I put those two lines before
self.Show() the window is rendered extremely small, and if I put it
afterwards the window doesn't change size at all.
Yeap, didn't notice that there was a panel in there which wasn't in a
sizer.
Added a sizer to the frame and add the panel to that sizer and then it
works.