navi2582 0 Newbie Poster

I am trying to toggle between the two toolbars and couldn't do it with the code below. Not sure where the problem is....

Any ideas are very welcome!!!

Here is the code:

`Inline Code Example Here`
import wx
import wx.grid
import wx.html
import wx.aui
from time import *
import cStringIO
import os
import subprocess

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

        self._perspectives = []
        self.n = 0
        self.x = 0

        tb4 = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize,
                         wx.TB_FLAT | wx.TB_NODIVIDER | wx.TB_HORZ_TEXT)
        tb4.SetToolBitmapSize(wx.Size(16,16))
        tb4_bmp1 = wx.ArtProvider_GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, wx.Size(16, 16))
        rwtool = tb4.AddLabelTool(101, "Read/Write", tb4_bmp1)
        tb4.AddSeparator()
        wtool = tb4.AddLabelTool(101, "Write", tb4_bmp1)
        tb4.AddSeparator()
        htool = tb4.AddLabelTool(101, "Help", tb4_bmp1)
        tb4.AddSeparator()
        tb4.Realize()

        self._mgr.AddPane(self.CreateRW(), wx.aui.AuiPaneInfo().Name("RW_content").
                          CenterPane().Hide())

        self._mgr.AddPane(self.CreateTest(), wx.aui.AuiPaneInfo().Name("TEST_content").
                          CenterPane().Hide())

        self._mgr.AddPane(tb4, wx.aui.AuiPaneInfo().
                          Name("tb4").Caption("Sample Bookmark Toolbar").
                          ToolbarPane().Top().Row(2).
                          LeftDockable(False).RightDockable(False))

        all_panes = self._mgr.GetAllPanes()

        for ii in xrange(len(all_panes)):
            if not all_panes[ii].IsToolbar():
                all_panes[ii].Hide()

        # "commit" all changes made to FrameManager
        self._mgr.Update()

        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        # Show How To Use The Closing Panes Event
        self.Bind(wx.aui.EVT_AUI_PANE_CLOSE, self.OnPaneClose)

        self.Bind(wx.EVT_TOOL, self.OnReadWrite, rwtool)
        self.Bind(wx.EVT_TOOL, self.OnTest, wtool)

    def OnClose(self, event):
        self._mgr.UnInit()
        del self._mgr
        self.Destroy()

    def OnPaneClose(self, event):

        caption = event.GetPane().caption

        if caption in ["Tree Pane", "Dock Manager Settings", "Fixed Pane"]:
            msg = "Are You Sure You Want To Close This Pane?"
            dlg = wx.MessageDialog(self, msg, "AUI Question",
                                   wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)

            if dlg.ShowModal() in [wx.ID_NO, wx.ID_CANCEL]:
                event.Veto()
            dlg.Destroy()

    def OnEraseBackground(self, event):
        event.Skip()

    def OnSize(self, event):
        self.Refresh()
        event.Skip()

    def OnTest(self, event):
        self._mgr.GetPane("RW_content").Show()
        #self._mgr.GetPane("TEST_content").Show()
        self._mgr.Update()

    def OnReadWrite(self, event):
        self._mgr.GetPane("TEST_content").Show()
        self._mgr.GetPane("RW_content").Show()
        self._mgr.Update()

    def CreateTest(self):
        self.panel = wx.Panel(self)
        StaticText = wx.StaticText
        TestText = StaticText(self.panel, -1, "Hello World!!!", (250, 250))

        return self.panel

    def CreateRW(self):

        self.panel = wx.Panel(self)

        StaticText = wx.StaticText

        pnLabel = StaticText(self.panel, -1, "Page Number", (50, 25))
        self.pnValue = wx.TextCtrl(self.panel,-1, "1", wx.Point(200, 25), wx.Size(150, 20),
                           wx.NO_BORDER | wx.TE_PROCESS_ENTER)

        return self.panel

#----------------------------------------------------------------------
class MyApp(wx.App):
    def __init__(self, redirect=False, filename=None):
       wx.App.__init__(self, redirect, filename)
       self.frame = wx.Frame(None, wx.ID_ANY, title='GUI')

       self.panel = wx.Panel(self.frame, wx.ID_ANY)
       frame = PyAUIFrame(self.panel, wx.ID_ANY, "GUI", size=(750, 590))
       frame.Show()

if __name__ == '__main__':
   app = MyApp()
   app.MainLoop()