Hi,
I looking for drawing an UI with floating frames in the auiManager.
The users will can drag tab from auinotebook to auinotebook or just drop tab in manager to form new frame,
but at this time I found noway to get an event when user drop a tab from auinotebook in window like the AUI_NB_TAB_FLOAT style gives the right to.
I need to know when a tab is floating in manager, that is my principal problem for now :
Follows a simply part of my code, if someone have an idea.
ty for help
Jocelyn.
···
first local module: main.py
import wx
import wx.lib.agw.aui as aui
personnal modules
from AuiNote import My_Notes_Book
#___________________________________
class AUIManager( aui.AuiManager ) :
“”" AUI Manager class “”"
def init( self, managed_window ) :
“”" “”"
aui.AuiManager.__init__( self )
self.SetManagedWindow( managed_window )
#_________________________________
class MyFrame(wx.Frame,My_Notes_Book):
def init(self):
wx.Frame.init(self, None, -1,“Find Item Example”,size=(900,800))
#init the manager
self._mgr = AUIManager(self)
#prepare two auinotebook
tabname = (" page 1one","page two","page three")
self.frame_one = self.flat(self,tabname)
tabname = (" page six ","page seven","page nine")
self.frame_two = self.flat(self,tabname)
self._mgr.AddPane(self.frame_one,aui.AuiPaneInfo().MinSize((200,200)).GripperTop(attop=True).Gripper(visible=True)
.GripperTop(attop=True).Float().Dockable(False).CloseButton(visible=False).FloatingPosition((150,150)))
self._mgr.AddPane(self.frame_two,aui.AuiPaneInfo().MinSize((200,200)).GripperTop(attop=True).Gripper(visible=True)
.GripperTop(attop=True).Float().Dockable(False).CloseButton(visible=False).FloatingPosition((150,250)))
self._mgr.Update()
def On_Close(self):
print 'fermeture'
if name == “main” :
app = wx.App()
frame = MyFrame()
frame.Show()
app.MainLoop()
**first local module: main.py
_________________________________________**import wx
import wx.lib.agw.aui as aui
import wx.lib.agw.flatnotebook as fnb
#------------------------------------------------------------------------------
#From the famous exemple all we can use
class TabPanel( wx.Panel ) :
“”" A simple wx.Panel class. “”"
def __init__( self, parent ) :
""" """
wx.Panel.__init__( self, parent=parent )
sizer = wx.BoxSizer( wx.VERTICAL )
txtOne = wx.TextCtrl( self, wx.ID_ANY, "" )
txtTwo = wx.TextCtrl( self, wx.ID_ANY, "" )
sizer = wx.BoxSizer( wx.VERTICAL )
sizer.Add( txtOne, 0, wx.ALL, 5 )
sizer.Add( txtTwo, 0, wx.ALL, 5 )
self.SetSizer( sizer )
#------------------------------------------------------------------------------
class My_Notes_Book:
def flat( self, parent,labels ) :
flat = aui.AuiNotebook(self,-1)
flat.SetAGWWindowStyleFlag(aui.AUI_NB_TAB_FLOAT | aui.AUI_NB_TOP | aui.AUI_NB_TAB_MOVE | aui.AUI_NB_TAB_EXTERNAL_MOVE | aui.AUI_NB_DRAW_DND_TAB )
pages = [TabPanel, TabPanel, TabPanel]
pageCtr = 1
for i,page in enumerate(pages) :
label = labels[i]
tab = page( flat )
flat.AddPage( tab, label, False )
pageCtr += 1
#all the binder I imagine I will need
flat.Bind(aui.EVT_AUINOTEBOOK_BEGIN_DRAG,self.OnDrag)
self.Bind(aui.EVT_AUINOTEBOOK_ALLOW_DND, self.OnAllowNotebookDnD)
flat.Bind(aui.EVT_AUINOTEBOOK_DRAG_MOTION,self.OnMove)
self.Bind(aui.EVT_AUINOTEBOOK_DRAG_DONE,self.OnTabEndDrag)
flat.Bind(aui.EVT_AUINOTEBOOK_DRAG_DONE,self.OnTabEndDrag)
return flat
def OnDrag(self,event):
print "DRAG"
event.Allow()
def OnMove (self,event):
ob =event.GetEventObject()
nt = ob.GetParent()
index = event.GetSelection()
print "pg",nt.GetPageText(index)
event.Allow()
def OnTabEndDrag(self,event):
#this event works when I drag a tab in the same auinotebook or in another one
# but it does not when I drag out of notebook to have a tabfloat pane..
print "drop"
event.Allow()
def OnAllowNotebookDnD(self,event):
print "ALLOW EVENT NOTE"
event.Allow()