How to make this work

Im having a stupid problem i cant solve …

I want a Frame with several panel inside then so only 1 panel is shown at once … the problem is that when the second panel shows the panel isnt stretched to the corners when i resize the frame.

im attaching an example of if (mind me on the button not correctly placed since i wrote it fast)

Thanks in advance.

sample.pyw (3.97 KB)

···


monoBOT

Visite mi sitio(Visit my site): monobotblog.alvarezalonso.es

You need to tell the sizer to layout when you hide/show your panel.

You might also want to consider sized_controls. Just for the heck of it I changed your sample to use the sc controls, see attached.

Werner

sample.py (3.39 KB)

···

On 01/03/2012 03:27, monoBOT wrote:

Im having a stupid problem i cant solve ...

I want a Frame with several panel inside then so only 1 panel is shown at once ... the problem is that when the second panel shows the panel isnt stretched to the corners when i resize the frame.

im attaching an example of if (mind me on the button not correctly placed since i wrote it fast)

Thanks Werner.

On your example you are using a different widget the problem persists.
Whats the advantage in that style over the simple wx.BoxSizer and
wx.FlexGridSizer? Is it that the next widget is placed correctly
instead of laying over the others?

And Ive tried to fix my example using Layout() that you recomended but
it didnt work either ...

Again thanks for the help

···

On 1 mar, 09:33, werner <wbru...@free.fr> wrote:

On 01/03/2012 03:27, monoBOT wrote:> Im having a stupid problem i cant solve ...

> I want a Frame with several panel inside then so only 1 panel is shown
> at once ... the problem is that when the second panel shows the panel
> isnt stretched to the corners when i resize the frame.

> im attaching an example of if (mind me on the button not correctly
> placed since i wrote it fast)

You need to tell the sizer to layout when you hide/show your panel.

You might also want to consider sized_controls. Just for the heck of it
I changed your sample to use the sc controls, see attached.

Werner

sample.py
4 KVerDescargar

Thanks Werner.

On your example you are using a different widget the problem persists.

Oops, missed two SetSizerProps calls, see attached.

Whats the advantage in that style over the simple wx.BoxSizer and
wx.FlexGridSizer? Is it that the next widget is placed correctly
instead of laying over the others?

The sized_controls handle most of the sizer stuff for you automatically and they have the advantage that the layout complies to the platform specific Human Interface Guidelines (HIG). Check out the wxPython demo for the different options.

But really just a matter of taste/liking.

And Ive tried to fix my example using Layout() that you recomended but
it didnt work either ...

You need to add the buttons to the appropriate sizer and the panels also need to be defined to expand (expand=True, proporation=1).

You might not have noticed it but I also used the WIT, so when running it press ctrl-alt-i, this tool is very helpful when debugging sizer issues as you easily look at each widget and see how large it is and what the sizer configuration is etc etc. See the wiki for more details: http://wiki.wxpython.org/Widget%20Inspection%20Tool

Werner

BTW - bottom posting is much easier to follow should this discussion go on a bit more:-) , and I believe that most of use on here prefer it.

sample.py (3.58 KB)

···

On 01/03/2012 16:10, monobot wrote:

Thanks Werner.

On your example you are using a different widget the problem persists.
Oops, missed two SetSizerProps calls, see attached.
Whats the advantage in that style over the simple wx.BoxSizer and

wx.FlexGridSizer? Is it that the next widget is placed correctly

instead of laying over the others?
The sized_controls handle most of the sizer stuff for you automatically and they have the advantage that the layout complies to the platform specific Human Interface Guidelines (HIG). Check out the wxPython demo for the different options.

But really just a matter of taste/liking.

Think i will consider it on my next proyect, but dont think i will change it on my current one.

And Ive tried to fix my example using Layout() that you recomended but

it didnt work either …
You need to add the buttons to the appropriate sizer and the panels also need to be defined to expand (expand=True, proporation=1).

You might not have noticed it but I also used the WIT, so when running it press ctrl-alt-i, this tool is very helpful when debugging sizer issues as you easily look at each widget and see how large it is and what the sizer configuration is etc etc. See the wiki for more details: http://wiki.wxpython.org/Widget%20Inspection%20Tool

Oh, now i see it … just checking it on the main application. (i will have to remember to take it out on the final app)

···

2012/3/1 werner wbruhin@free.fr

On 01/03/2012 16:10, monobot wrote:

Werner


monoBOT

Visite mi sitio(Visit my site): monobotblog.alvarezalonso.es

Hi,

···

On Wednesday, February 29, 2012 8:27:31 PM UTC-6, monobot wrote:

Im having a stupid problem i cant solve …

I want a Frame with several panel inside then so only 1 panel is shown at once … the problem is that when the second panel shows the panel isnt stretched to the corners when i resize the frame.

im attaching an example of if (mind me on the button not correctly placed since i wrote it fast)

Thanks in advance.


monoBOT

I wrote a little tutorial on panel switching a while back that you might find helpful: wxPython: How to Switch Between Panels - Mouse Vs Python

Notebook widgets serve a similar purpose too and wxPython has a whole bunch of different kinds of notebook-like controls.

  • Mike

Thanks to both of you … ill take a look on your tutorial now mike (i allways have your page near for consulting XD ) …

BTW i found a sollution, dont know if its very ellegant or not but … works:

on the frame:

self.Bind(wx.EVT_SIZE, self._onSize)

def _onSize(self, event):

event.Skip()

yourpanelnamehere.SetSize(self.GetClientSizeTuple())

so on every resizing the panel gets the size from its parent.

Thanks again Mike and werner

···


monoBOT

Visite mi sitio(Visit my site): monobotblog.alvarezalonso.es

monoBOT wrote:

    BTW i found a sollution, dont know if its very ellegant or

not but … works:

on the frame:

self.Bind(wx.EVT_SIZE, self._onSize)

def _onSize(self, event):

event.Skip()

yourpanelnamehere.SetSize(self.GetClientSizeTuple())

so on every resizing the panel gets the size from its parent.

There's nothing wrong with this solution.  If a change in the

parent’s size means that something must happen to the child windows,
then this is exactly how you’d do it. Usually, sizers handle this
for you, but when you don’t have a sizer, this is how you have to do
it.

···
-- Tim Roberts, Providenza & Boekelheide, Inc.

timr@probo.com