How to create tabbed MDI with wxSashLayoutWindow (example included)?

Hello!

I wrote my own very simple themed framework - i use MDI and 2 SashLayoutWindows with panels - top as my toolbar (i use my own background colour and some my controls) and bottom as simple status bar (with my background color).

How to simple rebuild this code (with my own toolbar & status bar controls) in order to use
tabbed interface (AuiMDIParentFrame) ?

Can i use AuiMDIParentFrame with wxLayoutAlgorithm ?
Or maybe i must use wxMDIClientWindow in special way?

In my application i want use 2 GUI: classic MDI or tabbed MDI (user can switch interface via opitions)

···

##############################################
import wx

use_aui = False
if not use_aui:
pf_class = wx.MDIParentFrame # parent frame class
cf_class = wx.MDIChildFrame # child frame class
else:
import wx.aui

pf_class = wx.aui.AuiMDIParentFrame

cf_class = wx.aui.AuiMDIParentFrame

def LayoutAlg(frame):
global use_aui
if use_aui:
wx.LayoutAlgorithm().LayoutFrame(frame)
else:
wx.LayoutAlgorithm().LayoutMDIFrame(frame)

##############################################
class CMainFrame(pf_class):
##############################################
def init(self, title, size):
global pf_class
pf_class.init(self, None, -1, title, size)

    wx.EVT_SIZE(self,self.__OnSize)
    wx.EVT_ACTIVATE(self,self.__OnActivate)

    self.topWin = wx.SashLayoutWindow(self, -1, style=0)
    self.topWin.SetDefaultSize((1000, 25))
    self.topWin.SetOrientation(wx.LAYOUT_HORIZONTAL)
    self.topWin.SetAlignment(wx.LAYOUT_TOP)
    self.topWin.SetBackgroundColour(wx.BLUE)

    self.bottomWin = wx.SashLayoutWindow(self, -1, style=0)

    self.bottomWin.SetDefaultSize((1000, 13))
    self.bottomWin.SetOrientation(wx.LAYOUT_HORIZONTAL)
    self.bottomWin.SetAlignment(wx.LAYOUT_BOTTOM)
    self.bottomWin.SetBackgroundColour(

wx.RED
)

def __OnSize(self, event):
    LayoutAlg(self)

def __OnActivate(self, event):
    if event.GetActive():
        LayoutAlg(self)

##############################################

class CFrame(cf_class):
##############################################
def init(self,parent, title):
cf_class.init(self,parent, wx.NewId(), title)
self.Bind(wx.EVT_ACTIVATE, self.__OnActivate)

def __OnActivate(self, event):

    if event.GetActive():
        LayoutAlg(self.GetParent())

ID_NEW_MI = wx.NewId()
ID_EXIT_MI = wx.NewId()

##############################################
class MyParentFrame(CMainFrame):

##############################################
def init(self):
CMainFrame.init(self, “MDI Parent”, size=(600,400))

    menu = wx.Menu()
    menu.Append(ID_NEW_MI, "&Add new frame")
    menu.AppendSeparator()
    menu.Append(ID_EXIT_MI, "&EXIT")
    menubar = wx.MenuBar()

    menubar.Append(menu, "&Menu")
    self.SetMenuBar(menubar)
    self.Bind(wx.EVT_MENU, self.OnNewWindow, id=ID_NEW_MI)
    self.Bind(wx.EVT_MENU, self.OnExit, id=ID_EXIT_MI)
    self.counter = 0
def OnExit(self, evt):
    self.Close(True)

def OnNewWindow(self, evt=None):
    self.counter += 1
    child_frame = CFrame(self, "Next child frame #"+str(

self.counter))

##############################################
class MyApp(wx.App):
##############################################
def OnInit(self):
frame = MyParentFrame()
frame.Maximize
()
frame.Show(True)

    self.SetTopWindow(frame)
    return True

if name == ‘main’:
app = MyApp(False)
app.MainLoop()

Wojtek P wrote:

Hello!

I wrote my own very simple themed framework - i use MDI and 2 SashLayoutWindows with panels - top as my toolbar (i use my own background colour and some my controls) and bottom as simple status bar (with my background color).

How to simple rebuild this code (with my own toolbar & status bar controls) in order to use
tabbed interface (AuiMDIParentFrame) ?

Can i use AuiMDIParentFrame with wxLayoutAlgorithm ?
Or maybe i must use wxMDIClientWindow in special way?

You can probably do it if you just use an AuiNotebook instead of the AuiMDI classes. The wxLayoutAlgorithm is real old, and AUI is real new, and I doubt they know how to talk to each other. (Kind of like teen-agers and fuddy-duddy parents. :wink: )

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!