wx.aui.AuiManager (Folge-Thread)
Verfasst: Donnerstag 1. März 2007, 00:23
Hands Thread wx.aui AUI_MDI und AUI_DockingWindowMgr integrieren? ist wohl wieder durch seinen extrem langen Source-Code blockiert. Ich finde es aber trotzdem interessant. Deshalb mache ich einen neuen Thread auf.
Die Lösung scheint zu sein, dass es sich nicht um AUI_MDI, sonder um ein AuiNotebook handelt. Ich glaube, folgendes Beispiel kommt Hands Vorstellungen schon recht nahe:MfG
HWK
Die Lösung scheint zu sein, dass es sich nicht um AUI_MDI, sonder um ein AuiNotebook handelt. Ich glaube, folgendes Beispiel kommt Hands Vorstellungen schon recht nahe:
Code: Alles auswählen
import wx
import wx.aui
text = """\
Hello!
Welcome to this little demo of draggable tabs using the wx.aui module.
To try it out, drag a tab from the top of the window all the way to the bottom.
After releasing the mouse, the tab will dock at the hinted position.
Then try it again with the remaining tabs in various other positions.
Finally, try dragging a tab to an existing tab ctrl.
You'll soon see that very complex tab layouts may be achieved.
"""
class TestPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)
self.nb = wx.aui.AuiNotebook(self)
page = wx.TextCtrl(self.nb, -1, text, style=wx.TE_MULTILINE)
self.nb.AddPage(page, "Welcome")
for num in range(1, 5):
page = wx.TextCtrl(self.nb, -1, "This is page %d" % num ,
style=wx.TE_MULTILINE)
self.nb.AddPage(page, "Tab Number %d" % num)
sizer = wx.BoxSizer()
sizer.Add(self.nb, 1, wx.EXPAND)
self.SetSizer(sizer)
class MyFrame(wx.Frame):
def __init__(self, parent, id=-1, title='wx.aui Test',
size=(800, 600), style=wx.DEFAULT_FRAME_STYLE):
wx.Frame.__init__(self, parent, id, title, (0,0), size, style)
self._mgr = wx.aui.AuiManager(self)
# create several text controls
text1 = wx.TextCtrl(self, -1, 'Pane 1 - sample text',
wx.DefaultPosition, wx.Size(200,150),
wx.NO_BORDER | wx.TE_MULTILINE)
text2 = wx.TextCtrl(self, -1, 'Pane 2 - sample text',
wx.DefaultPosition, wx.Size(200,150),
wx.NO_BORDER | wx.TE_MULTILINE)
notebook = TestPanel(self)
# add the panes to the manager
self._mgr.AddPane(text1, wx.LEFT, 'Pane Number One')
self._mgr.AddPane(text2, wx.BOTTOM, 'Pane Number Two')
self._mgr.AddPane(notebook, wx.CENTER)
# tell the manager to 'commit' all the changes just made
self._mgr.Update()
self.Bind(wx.EVT_CLOSE, self.OnClose)
def OnClose(self, event):
# deinitialize the frame manager
self._mgr.UnInit()
# delete the frame
self.Destroy()
app = wx.App(0)
frame = MyFrame(None)
frame.Show()
app.MainLoop()
HWK