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()