problems docking floating panels into a awg auiNotebook
Hi
I’d like to allow my users to be
able to undock Panes out of and redock back into an application created awg AuiNotebook.
I can’t figure out if this is a bug or I am just not calling the library
correctly.
In the window the following code creates,
if I drag the panel “One” into the notebook with tab
“Two” I end up with another auiNotebook containing panel
“One” and the original auiNotebook. I’ve spent most of my day
tracing through the code in wx.lib.awg.aui/framemanager.py and I’m still
none-the-wiser on how to achieve stop the extra notebook being created
(I’d like panel “One” to dock in my auiNotebook next to tab
“Two”).
Any ideas how I can achieve this?
If I drag the AuiManager created notebook,
One and Two out of the pane I can’t redock them into the App. Any ideas
what I need to do to allow that?
If I float the AuiManager created notebook
(with Two contained) out of the app I can’t dock One into it. Again is it
possible to do that?
Many thx
David
import wx
import wx.lib.agw.aui as aui
class TestFrame(wx.Frame):
def __init__(self):
wx.Frame.init(self, None, wx.ID_ANY, size=(600, 400), title=‘Notebook
Test’)
self.__auiManager = aui.AuiManager()
self.__auiManager.SetManagedWindow(self)
self.__auiNotebook = aui.AuiNotebook(self)
self.__auiNotebook.SetAGWWindowStyleFlag(
aui.AUI_NB_TAB_FLOAT | aui.AUI_NB_WINDOWLIST_BUTTON | aui.AUI_NB_SCROLL_BUTTONS
aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_TAB_SPLIT )
self.__auiManager.AddPane(self.__auiNotebook,
aui.AuiPaneInfo().Name(“Notebook”).
Center().CloseButton(False))
self.__auiManager.AddPane(self.CreateSizeReportCtrl(),
aui.AuiPaneInfo().Name(“test1”).Caption(“One”).
Left().CloseButton(False))
self.__auiManager.Update()
self.Bind(wx.EVT_CLOSE, self.WindowOnClose)
self.__auiNotebook.AddPage(self.CreateSizeReportCtrl(), “Two”)
def
CreateSizeReportCtrl(self, width=80, height=80):
return SizeReportCtrl(self, -1, wx.DefaultPosition, wx.Size(width, height),
self.__auiManager)
def WindowOnClose(self,
event):
self.Destroy()
class SizeReportCtrl(wx.PyControl):
def __init__(self,
parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize,
auiManager=None):
wx.PyControl.init(self, parent, id, pos, size, wx.NO_BORDER)
self.__auiManager = auiManager
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
def OnPaint(self,
event):
dc = wx.PaintDC(self)
size = self.GetClientSize()
s = (“Size: %d x %d”)%(size.x, size.y)
dc.SetFont(wx.NORMAL_FONT)
w, height = dc.GetTextExtent(s)
height = height + 3
dc.SetBrush(wx.WHITE_BRUSH)
dc.SetPen(wx.WHITE_PEN)
dc.DrawRectangle(0, 0, size.x, size.y)
dc.SetPen(wx.LIGHT_GREY_PEN)
dc.DrawLine(0, 0, size.x, size.y)
dc.DrawLine(0, size.y, size.x, 0)
dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2))
if self.__auiManager:
pi = self.__auiManager.GetPane(self)
s = ("%s")%pi.caption
w, h = dc.GetTextExtent(s)
dc.DrawText(s, (size.x-w)/2, ((size.y-(height5))/2)+(height1))
s = (“Layer: %d”)%pi.dock_layer
w, h = dc.GetTextExtent(s)
dc.DrawText(s, (size.x-w)/2, ((size.y-(height5))/2)+(height2))
s = (“Dock: %d Row: %d”)%(pi.dock_direction, pi.dock_row)
w, h = dc.GetTextExtent(s)
dc.DrawText(s, (size.x-w)/2, ((size.y-(height5))/2)+(height3))
s = (“Position: %d”)%pi.dock_pos
w, h =
dc.GetTextExtent(s)
dc.DrawText(s, (size.x-w)/2, ((size.y-(height5))/2)+(height4))
s = (“Proportion: %d”)%pi.dock_proportion
w, h = dc.GetTextExtent(s)
dc.DrawText(s, (size.x-w)/2, ((size.y-(height5))/2)+(height5))
def
OnEraseBackground(self, event):
intentionally empty
pass
def OnSize(self,
event):
self.Refresh()
event.Skip()
def main():
app = wx.PySimpleApp()
frame = TestFrame()
frame.Show()
app.SetTopWindow(frame)
app.MainLoop()
if name == “main”:
main()
disclaim.txt (1.59 KB)