Keep a Frame in an other window Frame
Question: My programm create a Frame with three panels in an horizontal boxsizer. A menu
with "new window" item for create a seconde Frame. I give the seconde panel as
parent of the seconde window. I wante the seconde Frame stays in the seconde
panel area of my first frame. if user move one of the two windows, the seconde
stays in the panel screen area. Do you know a way or something for that? I
tried a little something, but using is not very aesthetic.

and

    
    
    import wx
    
    class MainWindow(wx.Frame):
    
        def __init__(self,parent,id):
            wx.Frame.__init__(self,parent,id,'Python Test App',size=(600,400))
    
            #Widgets
            panel_gch = wx.Panel(self,-1,size = (150,-1))
            panel_gch.SetBackgroundColour('white')
            self.panel=wx.Panel(self,-1,size=(300,400))
            self.panel.SetBackgroundColour((200,230,200))
            panel_drt = wx.Panel(self,-1,size = (150,-1))
            panel_drt.SetBackgroundColour('white')
            box = wx.BoxSizer(wx.HORIZONTAL)
            self.SetSizer(box)
    
            #Add
            box.Add(panel_gch,0,wx.EXPAND)
            box.Add(self.panel,1,wx.EXPAND)
            box.Add(panel_drt,0,wx.EXPAND)
    
            #Menu
            status=self.CreateStatusBar()
            menubar=wx.MenuBar()
            file_menu=wx.Menu()
            ID_FILE_NEW = 1
            file_menu.Append(ID_FILE_NEW,"New Window","This is a new window")
            menubar.Append(file_menu,"File")
            self.SetMenuBar(menubar)
    
            #bind and layout
            self.Bind(wx.EVT_MENU, self.get_new_window)
            panel_gch.Layout()
            self.panel.Layout()
            panel_drt.Layout()
            self.Layout()
    
        def get_new_window(self,event): # create new window
            self.new = NewWindow(self.panel,-1)
            self.new.Show(True)
            self.new.Bind(wx.EVT_MOVE,self.window2_on_move)
    
        def window2_on_move(self,event): # Window2 must stay in
            x, y = event.GetPosition()
            v,w =self.panel.GetScreenPosition()
            s,t = self.panel.GetClientSizeTuple()
            if x < v:
                self.new.Move((v,-1))
            if y < w:
                self.new.Move((-1,w))
            if x+200 > v+s:
                self.new.Move((v+s-200,-1))
            if y+200 > w+t:
                self.new.Move((-1,w+t-200))    
    
    class NewWindow(wx.MiniFrame):
    
        def __init__(self,MainWindow,id):
            wx.MiniFrame.__init__(self, MainWindow, id, 'New Window', size=(200,200),\
                                  style = wx.MINIMIZE | wx.CAPTION | wx.CLOSE_BOX | wx.CLOSE_BOX)
            self.CenterOnParent()
    
    
    if __name__=='__main__':
            app=wx.PySimpleApp()
            frame=MainWindow(parent=None,id=-1)
            frame.Show()
            app.MainLoop()
    


Answer: What you probably want is AUI. I personally recommend the wx.lib.agw.aui set
rather than wx.aui as the former is pure Python and has had a LOT more recent
work done on it. There are multiple examples in the wxPython demo package. You
can also read about it here:

  * <http://wxpython.org/Phoenix/docs/html/lib.agw.aui.framemanager.AuiManager.html>

