Sizer

Hello everybody,

I am just new to this group and to wxPython, i am french and I apologize for my poor English.

I want to have a main window with sliders and a “More controllers” button on it.

When I click on “More controllers” button a subwindow open showing others sliders.

My problem is if I use the sizer method on the subwindow I can’t see any sliders on this subwindow !!

Have included the file Sizer_test.py, a “reduced” (no button) version for test.

Normally it should display a main window with two sliders and a subwindow with two sliders.

I can’t find my mistake. (I am on Ubuntu 10.04 with wxpython 2.8)

Thanks for help

Djack

Sizer_test.py (1.51 KB)

Hello Djack,

On Windows XP SP3, wxPython 2.8.11.0 and Python 2.6, the 2 windows
show up
without problem although a little small.
I can see the 2 sliders.

Anyway, I think you should:
- attach your gridbagsizer to the panel instead of self in the
subwindow,
panel.SetSizer(sizer1)
- add panel.Fit()
- increase the size of your subwindow,
I never put SetSizeHints, but I may be wrong !! I am not a
professionnal!

Dominique

···

On 5 déc, 18:17, Rene Jopi <rene.j...@gmail.com> wrote:

Hello everybody,

I am just new to this group and to wxPython, i am french and I apologize for
my poor English.

I want to have a main window with sliders and a "More controllers" button on
it.
When I click on "More controllers" button a subwindow open showing others
sliders.

My problem is if I use the sizer method on the subwindow I can't see any
sliders on this subwindow !!

Have included the file Sizer_test.py, a "reduced" (no button) version for
test.
Normally it should display a main window with two sliders and a subwindow
with two sliders.

I can't find my mistake. (I am on Ubuntu 10.04 with wxpython 2.8)
Thanks for help
Djack

Sizer_test.py
2KAfficherTélécharger

Hi Djack,

here is your code with the small corrections.
Test on Windows 7, wxPython 2.8.11.0 and Python 2.7.

#!/usr/bin/python
# -*- coding: latin-1 -*-

import wx

class Sub_Window(wx.Frame):
    def __init__(self, parent, size=(200,200), position=(300,300)):
        wx.Frame.__init__(self, parent, -1, title="Sub Window",
size=size, pos=position)

        panel = wx.Panel(self, -1)
        self.GrAmpCtrl = wx.Slider(panel, -1, 250, 0, 400, (0, 0),
(90,35), wx.SL_HORIZONTAL | wx.SL_LABELS )
        self.GrFreqCtrl = wx.Slider(panel, -1, 14, 1, 1500, (0, 0),
(90,35), wx.SL_HORIZONTAL | wx.SL_LABELS )

        sizer1 = wx.GridBagSizer(10, 10)
        sizer1.Add(self.GrAmpCtrl, (2,1))
        sizer1.Add(self.GrFreqCtrl, (4,1))
        sizer1.SetSizeHints(panel) ##### panel
        panel.SetSizer(sizer1) ##### panel

class GUI(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__( self, parent, -1)

        self.GrAmpCtrl = wx.Slider(self, -1, 250, 0, 400, (0, 0),
(90,35), wx.SL_HORIZONTAL | wx.SL_LABELS )
        self.GrFreqCtrl = wx.Slider(self, -1, 14, 1, 1500, (0, 0),
(90,35), wx.SL_HORIZONTAL | wx.SL_LABELS )

        sizer1 = wx.GridBagSizer(10, 10)
        sizer1.Add(self.GrAmpCtrl, (2,1))
        sizer1.Add(self.GrFreqCtrl, (4,1))
        sizer1.SetSizeHints(self)
        self.SetSizer(sizer1)
        window = Sub_Window(parent, (300,300), (800,0))
  window.Show(True)

application = wx.PySimpleApp()
frame = wx.Frame( None, -1, "Main Window", pos=(0,0))
guiMain = GUI(frame)

frame.Show(True)
application.MainLoop()

Good continuation,
CJC.

You should assign the sizer to the panel, not to self. The items being managed by the sizer are children of the panel, and so it is the panel who should be responsible for their layout, so it is the panel that needs the sizer with those items in it.

···

On 12/5/10 9:17 AM, Rene Jopi wrote:

Hello everybody,

I am just new to this group and to wxPython, i am french and I apologize
for my poor English.

I want to have a main window with sliders and a "More controllers"
button on it.
When I click on "More controllers" button a subwindow open showing
others sliders.

My problem is if I use the sizer method on the subwindow I can't see any
sliders on this subwindow !!

Have included the file Sizer_test.py, a "reduced" (no button) version
for test.
Normally it should display a main window with two sliders and a
subwindow with two sliders.

I can't find my mistake. (I am on Ubuntu 10.04 with wxpython 2.8)

--
Robin Dunn
Software Craftsman

Hello,

I want to thanks you all for your answers and explanation.
It is now working and I understand why :))
Thanks
Djack

···

On 6 déc, 19:26, Robin Dunn <ro...@alldunn.com> wrote:

On 12/5/10 9:17 AM, Rene Jopi wrote:

> Hello everybody,

> I am just new to this group and to wxPython, i am french and I apologize
> for my poor English.

> I want to have a main window with sliders and a "More controllers"
> button on it.
> When I click on "More controllers" button a subwindow open showing
> others sliders.

> My problem is if I use the sizer method on the subwindow I can't see any
> sliders on this subwindow !!

> Have included the file Sizer_test.py, a "reduced" (no button) version
> for test.
> Normally it should display a main window with two sliders and a
> subwindow with two sliders.

> I can't find my mistake. (I am on Ubuntu 10.04 with wxpython 2.8)

You should assign the sizer to the panel, not to self. The items being
managed by the sizer are children of the panel, and so it is the panel
who should be responsible for their layout, so it is the panel that
needs the sizer with those items in it.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org