Seeking help regarding PyAUI and AddPane

Hi,

I'm getting acquainted with wx.aui.AuiManager(). In the demo each pane
is a single control. My goal is to have a single pane containing
multiple controls (e.g. one pane with 10 buttons). So far I've tried
two methods, my own class (class MenuFrame(wx.Frame), and a
wx.GridBagSizer. In both instances I get the error "argument 2 expects
type 'wxWindow *'

I'm posting my code below. I am using pythong 2.5.1, and wxPython
2.8.4.2 on a Windows XP machine.

I greatly appreciate any feedback as to how to achieve this result.
Thank-you!!

···

---------------------------------------------------------------------------------------------------------------------------------------------------------------
## import win32com.client, win32api
## import os,sys
## #Path for importing psspy & redirect
## sys.path.append("C:\Program Files\PTI\PSSE30\PSSBIN")
## os.environ['PATH']+=";C:\Program Files\PTI\PSSE30\PSSBIN"
## os.environ['PATH']+=";C:\Program Files\PTI\PSSE30\PSSLIB"
## # end:path
## import psspy
## import redirect
## redirect.psse2py()
## psspy.psseinit(80000)
## _i = psspy._i
## _f = psspy._f

import wx
import wx.grid
import wx.html
import wx.aui

import cStringIO

ID_btn_DisplayMenu = wx.NewId()
ID_btn_OpenBC = wx.NewId()

class MenuFrame(wx.Frame):
    def __init__(self, parent, id=-1, title="",
pos=wx.DefaultPosition,
                 size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE |
                                            wx.SUNKEN_BORDER |
                                            wx.CLIP_CHILDREN):
        b=wx.Button(parent,wx.NewId(),"b")

class MainFrame(wx.Frame):
    def __init__(self, parent, id=-1, title="",
pos=wx.DefaultPosition,
                 size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE |
                                            wx.SUNKEN_BORDER |
                                            wx.CLIP_CHILDREN):

        wx.Frame.__init__(self, parent, id, title, pos, size, style)

        # tell FrameManager to manage this frame
        self._mgr = wx.aui.AuiManager()
        self._mgr.SetManagedWindow(self)

        mb = wx.MenuBar()
        file_menu = wx.Menu()
        file_menu.Append(wx.ID_EXIT, "Exit")
        mb.Append(file_menu, "File")
        self.SetMenuBar(mb)

#-----------BEGIN: toolbar-------------
        tb1 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
                         wx.TB_FLAT | wx.TB_NODIVIDER)
        ctrl1=wx.Button(tb1,ID_btn_DisplayMenu,"Display Menu")
        #ctrl2 OPEN BASE CASE
        tb1.AddControl(ctrl1)
        tb1.Realize()
#-----------END: toolbar---------------
#-----------BEGIN: grid----------------
        grid=wx.GridBagSizer(10,10)
        btn=[]
        for i in xrange(10):
            btn.append([wx.NewId()])
            btn[i].append(wx.Button(self,btn[i][0],"bob"))
        for i in xrange(2):
            for j in xrange(5):
                grid.Add(btn[5*i+j][1],(j,i))
#-----------END: grid------------------
#-----------BEGIN: test panes----------
        ctrl=wx.TextCtrl(self, -1, "If supported by the native
control, this is red, and this is a different font.",
                         size=(200, 100), style=wx.TE_MULTILINE|
wx.TE_RICH2)
        ctrl2=wx.TextCtrl(self, -1, "If supported by the native
control, this is red, and this is a different font.",
                         size=(200, 100), style=wx.TE_MULTILINE|
wx.TE_RICH2)
        menu= MenuFrame(self, title="Menu")
        self._mgr.AddPane(ctrl, wx.aui.AuiPaneInfo().
                          Name("test8").Caption("Tree Pane").
                          Left().Layer(1).Position(1).CloseButton
(True).MaximizeButton(True))
        self._mgr.AddPane(ctrl2, wx.aui.AuiPaneInfo().
                          Name("test2").Caption("Tree Pane").
                          Bottom().Layer(1).Position(1).CloseButton
(True).MaximizeButton(True))
##------attempt to add pane of wx.GridBagSizer----------
## self._mgr.AddPane(grid, wx.aui.AuiPaneInfo().
## Name("MenuB").Caption("bob").
## Right().Layer(1).Position(1).CloseButton
(True).MaximizeButton(True))
##------alternate attempt to add pane of user class
MenuFrame----------
## self._mgr.AddPane(menu, wx.aui.AuiPaneInfo().
## Name("MenuB").Caption("bob").
## Right().Layer(1).Position(1).CloseButton
(True).MaximizeButton(True))

#-----------END: test panes----------
        self._mgr.AddPane(tb1, wx.aui.AuiPaneInfo().Name("tb1").Caption
("Navigate").ToolbarPane().
                          Top().Dockable(False).Floatable
(False).Gripper(False))
# self._mgr.GetPane("tb1").Show()
        self._mgr.Update()

b= wx.App()
a= MainFrame(None, wx.ID_ANY, "Demo", size=(750, 590))
a.Show()
b.MainLoop()

Hi,

2010/1/27 lugh:

Hi,

I'm getting acquainted with wx.aui.AuiManager(). In the demo each pane
is a single control. My goal is to have a single pane containing
multiple controls (e.g. one pane with 10 buttons). So far I've tried
two methods, my own class (class MenuFrame(wx.Frame), and a
wx.GridBagSizer. In both instances I get the error "argument 2 expects
type 'wxWindow *'

I'm posting my code below. I am using pythong 2.5.1, and wxPython
2.8.4.2 on a Windows XP machine.

I greatly appreciate any feedback as to how to achieve this result.
Thank-you!!

You've already been given some good suggestions on wx-users (or
wx-dev, I don't remember). You can not add a wx.Frame to wxAUI because
wx.Frame is a toplevel window and it is not an instance of wx.Window.
You can not add a wx.GridBagSizer because a sizer is not a window at
all. You can add panels, textctrls, treectrls, basically anything else
deriving from wx.Window.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

You've already been given some good suggestions on wx-users (or
wx-dev, I don't remember). You can not add a wx.Frame to wxAUI because
wx.Frame is a toplevel window and it is not an instance of wx.Window.
You can not add a wx.GridBagSizer because a sizer is not a window at
all. You can add panels, textctrls, treectrls, basically anything else
deriving from wx.Window.

Yes, you're 100% right. I've been told that my approach won't work,
but I've already discovered that on my own. That's why I came to these
forums to learn what the -right- method is. I switched forums for the
same reason; I already know the method I'm using is wrong, I'm hoping
someone would tell me how to actually display 10 buttons in a single
pane?

I would look at the source code for wx.TextCtrl to see how that class
is derived and what makes it compatible with wx.AUI, but I do not have
rights on this machine to download it.

You mention above that only classes derived from wx.Window works. I've
tried that to no success. About 5 minutes ago I tried inheriting
wx.PyWindow, and that seems to let me show 1 button but I haven't
figured out yet how to show more than one (it ignores the rest). You
also mention a panel class... I think I'll try that next. Sorry if I
seem a little dense, or if I came across as arrogant or ungrateful. I
started with wxPython last week, I couldn't find an example of what I
wanted to do in the demos, and my attempts to do it myself are hitting
a wall.

Hi,

2010/1/27 lugh:

You've already been given some good suggestions on wx-users (or
wx-dev, I don't remember). You can not add a wx.Frame to wxAUI because
wx.Frame is a toplevel window and it is not an instance of wx.Window.
You can not add a wx.GridBagSizer because a sizer is not a window at
all. You can add panels, textctrls, treectrls, basically anything else
deriving from wx.Window.

Yes, you're 100% right. I've been told that my approach won't work,
but I've already discovered that on my own. That's why I came to these
forums to learn what the -right- method is. I switched forums for the
same reason; I already know the method I'm using is wrong, I'm hoping
someone would tell me how to actually display 10 buttons in a single
pane?

I would look at the source code for wx.TextCtrl to see how that class
is derived and what makes it compatible with wx.AUI, but I do not have
rights on this machine to download it.

You mention above that only classes derived from wx.Window works. I've
tried that to no success. About 5 minutes ago I tried inheriting
wx.PyWindow, and that seems to let me show 1 button but I haven't
figured out yet how to show more than one (it ignores the rest). You
also mention a panel class... I think I'll try that next. Sorry if I
seem a little dense, or if I came across as arrogant or ungrateful. I
started with wxPython last week, I couldn't find an example of what I
wanted to do in the demos, and my attempts to do it myself are hitting
a wall.

I believe you are doing/viewing things in a waaay over-complicated
manner. If you want to add a panel with some buttons in it to a wxAUI
pane, you can simply do this:

panel = wx.Panel(self)
btn1 = wx.Button(panel, -1, "Button 1")
btn2 = wx.Button(panel, -1, "Button 2")
btn3 = wx.Button(panel, -1, "Button 3")

sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(btn1, 0, wx.ALL, 5)
sizer.Add(btn2, 0, wx.ALL, 5)
sizer.Add(btn3, 0, wx.ALL, 5)

panel.SetSizer(sizer)
sizer.Layout()

self._mgr.AddPane(panel,
wx.aui.AuiPaneInfo().Left().Caption("Whatever").Name("Hello")

Where "self" is your wxAUI managed window and "self._mgr" is the
wx.aui.AuiManager.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/

I believe you are doing/viewing things in a waaay over-complicated
manner. If you want to add a panel with some buttons in it to a wxAUI
pane, you can simply do this:

Wow, thank-you so much! Either I missed a demo with panels, or my head
is still stuck in another language. The last time I wrote a gui was
using visual studio 95 c++. Apparently I have some catching up to do.
I was excited when I first saw wx.AUI, depressed when I couldn't
figure out the panel bit. Anyway, thanx again.