Tiered Widget Setup?

Hi,

I am pretty new to python and wxPython but am loving it!

I have spent the last few days mastering all of the basics of each and
every widget. They all make plenty of sense when creating it in
isolation. However I am still having issues getting them to work well
together.

As I have been learning wxPython I have been trying to create a tiered
widget setup that has proven particularly difficult.

    a NOTEBOOK, containing a>
        PANEL, that scrollable via a>
            SCROLLING WINDOW, which just above the bottom scroll bar
has a>
                SLIDER, then above the slider have a few...
                PLATE BUTTONS...

The program below does not included the Scrolling Window, Slider, nor
the Plate Buttons, as I cannot for the life of me figure out how to
get them created as children of the Panel.

Hopefully what I am describing is clear enough, but I am curious as to
whether it is possible to create this type of tiered setup?

Also I do not know how at attach pictures or .py files to these
discussions, if anyone could assist in that also it would be greatly
appreciated.

Cheers,

-Cort

Here is my current setup.
Windows XP 32bit.
Python 2.6
wxPython 2.8

### -- START OF EXAMPLE PROGRAM --

import wx
import wx.aui
import wx.lib.scrolledpanel as scroll

#Defining File Menu Options
ID_OPEN = 101

class NBPanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        t = wx.StaticText(self, -1, "1. The Notebook is currently the
parent of this Panel."
                          "\n2. I am try to create a Scrolling Window
that occupys the entire contents of the parent Panel."
                          "\n3. Inside the Scrolling Window I want a
Slider at the bottom of the Panel just above the Scrolling Bar."
                          "\n4. Inside the Panel above the Slider I
want to put a few Plate Buttons.\n"
                          "\n Notebook>"
                          "\n Panel>"
                          "\n Scrolling Window>"
                          "\n Slider..."
                          "\n Plate Buttons...",
(5,25))

class RootFrame(wx.Frame):

    def __init__(self, parent, id = -1, title = "Audio Interpreter",
                 pos = wx.DefaultPosition, size = (800, 400),
                 style = wx.DEFAULT_FRAME_STYLE):
        # -- Init for RootFrame --
        wx.Frame.__init__(self, parent, id, title, pos, size, style)

        # -- Enabling the AUI Manager --
        self._mgr = wx.aui.AuiManager(self)

        # -- Adding StatusBar --
        self.CreateStatusBar() # - Status Bar

        # -- Adding MenuBar --
        filemenu = wx.Menu()
        filemenu.Append(ID_OPEN, "&Open...", "Opens a Saved TTY File")
        menubar = wx.MenuBar()
        menubar.Append(filemenu, "&File")
        self.SetMenuBar(menubar)

        # -- Creating Notebook and its child Panel --
        nb = wx.Notebook(self)
        ttytab = NBPanel(nb)

        # -- Adding a single page to the Notebook
        nb.AddPage(ttytab, "Mon Aug 31 15-24-23 2009")

        # -- Creating a Scroll Window for the Far Left Section --
        eventpanel = scroll.ScrolledPanel(self, -1, size =(120, 275),
style = wx.TAB_TRAVERSAL, name ="Event Panel" )
        eventpanelpanelsizer = wx.FlexGridSizer(cols = 2, vgap = 4,
hgap = 4)

        eventpanel.SetSizer(eventpanelpanelsizer)
        eventpanel.SetAutoLayout(1)
        eventpanel.SetupScrolling()
        # --

        # -- Sizer for the Root Frame --
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(eventpanel, 1, wx.EXPAND)
        sizer.Add(nb, 4.5, wx.EXPAND)
        self.SetSizerAndFit(sizer)

        self._mgr.Update()
        self.Show(True)

app = wx.App()
frame = RootFrame(None)
app.MainLoop()
del app

### -- END OF EXAMPLE PROGRAM --

The scrolling windows should be a child of the notebook panel, the
plate buttons should be children of the scrolling window.
You do this by setting the "parent" argument of each widget to its
proper parent.

···

On Tue, Sep 1, 2009 at 8:10 AM, Cort Soest<csoest@gmail.com> wrote:

Hi,

I am pretty new to python and wxPython but am loving it!

I have spent the last few days mastering all of the basics of each and
every widget. They all make plenty of sense when creating it in
isolation. However I am still having issues getting them to work well
together.

As I have been learning wxPython I have been trying to create a tiered
widget setup that has proven particularly difficult.

a NOTEBOOK, containing a>
PANEL, that scrollable via a>
SCROLLING WINDOW, which just above the bottom scroll bar
has a>
SLIDER, then above the slider have a few...
PLATE BUTTONS...

The program below does not included the Scrolling Window, Slider, nor
the Plate Buttons, as I cannot for the life of me figure out how to
get them created as children of the Panel.

Hopefully what I am describing is clear enough, but I am curious as to
whether it is possible to create this type of tiered setup?

Also I do not know how at attach pictures or .py files to these
discussions, if anyone could assist in that also it would be greatly
appreciated.

Cheers,

-Cort

Here is my current setup.
Windows XP 32bit.
Python 2.6
wxPython 2.8

### -- START OF EXAMPLE PROGRAM --

import wx
import wx.aui
import wx.lib.scrolledpanel as scroll

#Defining File Menu Options
ID_OPEN = 101

class NBPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
t = wx.StaticText(self, -1, "1. The Notebook is currently the
parent of this Panel."
"\n2. I am try to create a Scrolling Window
that occupys the entire contents of the parent Panel."
"\n3. Inside the Scrolling Window I want a
Slider at the bottom of the Panel just above the Scrolling Bar."
"\n4. Inside the Panel above the Slider I
want to put a few Plate Buttons.\n"
"\n Notebook>"
"\n Panel>"
"\n Scrolling Window>"
"\n Slider..."
"\n Plate Buttons...",
(5,25))

class RootFrame(wx.Frame):

def __init__(self, parent, id = -1, title = "Audio Interpreter",
pos = wx.DefaultPosition, size = (800, 400),
style = wx.DEFAULT_FRAME_STYLE):
# -- Init for RootFrame --
wx.Frame.__init__(self, parent, id, title, pos, size, style)

   \# \-\- Enabling the AUI Manager \-\-
   self\.\_mgr = wx\.aui\.AuiManager\(self\)

   \# \-\- Adding StatusBar \-\-
   self\.CreateStatusBar\(\) \# \- Status Bar

   \# \-\- Adding MenuBar \-\-
   filemenu = wx\.Menu\(\)
   filemenu\.Append\(ID\_OPEN, &quot;&amp;Open\.\.\.&quot;, &quot;Opens a Saved TTY File&quot;\)
   menubar = wx\.MenuBar\(\)
   menubar\.Append\(filemenu, &quot;&amp;File&quot;\)
   self\.SetMenuBar\(menubar\)

   \# \-\- Creating Notebook and its child Panel \-\-
   nb = wx\.Notebook\(self\)
   ttytab = NBPanel\(nb\)

   \# \-\- Adding a single page to the Notebook
   nb\.AddPage\(ttytab, &quot;Mon Aug 31 15\-24\-23 2009&quot;\)

   \# \-\- Creating a Scroll Window for the Far Left Section \-\-
   eventpanel = scroll\.ScrolledPanel\(self, \-1, size =\(120, 275\),

style = wx.TAB_TRAVERSAL, name ="Event Panel" )
eventpanelpanelsizer = wx.FlexGridSizer(cols = 2, vgap = 4,
hgap = 4)

   eventpanel\.SetSizer\(eventpanelpanelsizer\)
   eventpanel\.SetAutoLayout\(1\)
   eventpanel\.SetupScrolling\(\)
   \# \-\-

   \# \-\- Sizer for the Root Frame \-\-
   sizer = wx\.BoxSizer\(wx\.HORIZONTAL\)
   sizer\.Add\(eventpanel, 1, wx\.EXPAND\)
   sizer\.Add\(nb, 4\.5, wx\.EXPAND\)
   self\.SetSizerAndFit\(sizer\)

   self\.\_mgr\.Update\(\)
   self\.Show\(True\)

app = wx.App()
frame = RootFrame(None)
app.MainLoop()
del app

### -- END OF EXAMPLE PROGRAM --

>

--
There is NO FATE, we are the creators.
blog: http://damoc.ro/

I am pretty new to python and wxPython but am loving it!

Welcome!

I have spent the last few days mastering all of the basics of each and
every widget.

That's impressive.

As I have been learning wxPython I have been trying to create a tiered
widget setup that has proven particularly difficult.

a NOTEBOOK, containing a>
PANEL, that scrollable via a>
SCROLLING WINDOW, which just above the bottom scroll bar
has a>
SLIDER, then above the slider have a few...
PLATE BUTTONS...

The program below does not included the Scrolling Window, Slider, nor
the Plate Buttons, as I cannot for the life of me figure out how to
get them created as children of the Panel.

As Peter said, you have to tell it who its parent is. Here:

        eventpanel = scroll.ScrolledPanel(self, -1, size =(120, 275),
           style = wx.TAB_TRAVERSAL, name ="Event Panel" )

You are saying that eventpanel's parent is the frame (because the
first argument is self--that is, the frame), when you actually want it
to be the notebook.

Hopefully what I am describing is clear enough, but I am curious as to
whether it is possible to create this type of tiered setup?

Sure this kind of "tiered" as you say, or "nested" as I might think of it,
is common. But to simplify, I think you can just skip the the panel and
make the scrolling panel the notebook page (as I understand it, a scrolling
panel is just a panel that scrolls).

Also I do not know how at attach pictures or .py files to these
discussions, if anyone could assist in that also it would be greatly
appreciated.

If you subscribe to the list through email, you can just attach
pictures or files to your email as you normally would. I find that
Gmail works well to allow one to star or label threads that might
helpful in the future.

HTH,
Che

A ScrolledPanel would probably work...but he mentioned a
ScrolledWindow...I'm not sure you can use that for a notebook page. I
tried to do what he was talking about, but had trouble getting plate
buttons to even show up on a ScrolledWindow. No errors, but no widgets
either. Odd.

···

On Sep 1, 10:09 am, C M <cmpyt...@gmail.com> wrote:

> I am pretty new to python and wxPython but am loving it!

Welcome!

> I have spent the last few days mastering all of the basics of each and
> every widget.

That's impressive.

> As I have been learning wxPython I have been trying to create a tiered
> widget setup that has proven particularly difficult.

> a NOTEBOOK, containing a>
> PANEL, that scrollable via a>
> SCROLLING WINDOW, which just above the bottom scroll bar
> has a>
> SLIDER, then above the slider have a few...
> PLATE BUTTONS...

> The program below does not included the Scrolling Window, Slider, nor
> the Plate Buttons, as I cannot for the life of me figure out how to
> get them created as children of the Panel.

As Peter said, you have to tell it who its parent is. Here:

    eventpanel = scroll\.ScrolledPanel\(self, \-1, size =\(120, 275\),
       style = wx\.TAB\_TRAVERSAL, name =&quot;Event Panel&quot; \)

You are saying that eventpanel's parent is the frame (because the
first argument is self--that is, the frame), when you actually want it
to be the notebook.

> Hopefully what I am describing is clear enough, but I am curious as to
> whether it is possible to create this type of tiered setup?

Sure this kind of "tiered" as you say, or "nested" as I might think of it,
is common. But to simplify, I think you can just skip the the panel and
make the scrolling panel the notebook page (as I understand it, a scrolling
panel is just a panel that scrolls).

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

Mike Driscoll wrote:

A ScrolledPanel would probably work...but he mentioned a
ScrolledWindow...I'm not sure you can use that for a notebook page.

It can. The ScrolledPanel class is derived from ScrolledWindow, which is derived from Panel, so they're all related.

···

--
Robin Dunn
Software Craftsman

Thank you guys very much so far for your responses. I will take a shot
at it again today.

···

On Sep 1, 9:48 am, Robin Dunn <ro...@alldunn.com> wrote:

Mike Driscoll wrote:

> A ScrolledPanel would probably work...but he mentioned a
> ScrolledWindow...I'm not sure you can use that for a notebook page.

It can. The ScrolledPanel class is derived from ScrolledWindow, which
is derived from Panel, so they're all related.

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