[wxPython] own maximize for wxMDIChildFrame - bugs?



I use code below:
1) frame receive too many maximize events on create and on close child window - why?
2) how to catch key events for wxMDIParentFrame ?
3) childWin.SetSize() in OnMaximize send additional maximize event (?)
4) wxMDIChildFrame is initially visible!
5) sorry for english :)
6) wxPython 2.5.4.1 (Windows)

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

#----------------------------------------------------------------------

class MyParentFrame(wx.MDIParentFrame):
    def __init__(self):
        wx.MDIParentFrame.__init__(self, None, -1, "MDI Parent", size=(600,400), style=wx.DEFAULT_FRAME_STYLE|wx.FRAME_NO_WINDOW_MENU)
        self.winCount = 0

        self.CreateStatusBar()
        self.MainTb=self.CreateToolBar(wx.TB_HORIZONTAL|wx.NO_BORDER|wx.TB_FLAT)
        biblioBut=wx.Button(self.MainTb,1231,label="&Biblio")
        newWndBut=wx.Button(self.MainTb,1213,label="&NewWnd")
        wx.EVT_BUTTON(self,newWndBut.GetId(), self.OnNewWindow)
        self.MainTb.AddControl(biblioBut)
        self.MainTb.AddSeparator()
        self.MainTb.AddControl(newWndBut)
        self.MainTb.Realize()
        self.SetToolBar(self.MainTb)
        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDownParent)


def OnKeyDownParent(self, event): print "OnKeyDownParent"

    def OnKeyDownChild(self, event):
        print "OnKeyDownChild"

    def OnClose(self, evt):
        self.GetActiveChild().Close(True)

    def OnMaximize(self, event):
        childWin = event.GetEventObject()
        win = childWin.GetParent()
        print "maximize "+self.GetTitle()
        childWin.SetSize(wx.Size(win.GetClientSize().GetWidth(),win.GetClientSize().GetHeight()-1))
        childWin.SetPosition(wx.Point(0,-1*win.GetClientAreaOrigin().y+1))
        event.Skip()

    def OnNewWindow(self,event):
        self.winCount = self.winCount + 1
        win = wx.MDIChildFrame(self, -1, "Child Window: %d" % self.winCount)
        win.Maximize()
        #win.Show() # !!!!!!!!!!!!!!!!!!

        MainTb=win.CreateToolBar(wx.TB_HORIZONTAL|wx.NO_BORDER|wx.TB_FLAT)
        SBut=wx.Button(MainTb,1213,label="&Func")
        MainTb.AddControl(SBut)
        MainTb.Realize()
        win.SetToolBar(MainTb)

        win.Bind(wx.EVT_MAXIMIZE, self.OnMaximize)
        win.Bind(wx.EVT_KEY_DOWN, self.OnKeyDownChild)
        win.Show(True)

#----------------------------------------------------------------------

if __name__ == '__main__':
    class MyApp(wx.App):
        def OnInit(self):
            wx.InitAllImageHandlers()
            frame = MyParentFrame()
            frame.Show(True)
            self.SetTopWindow(frame)
            return True

    app = MyApp(False)
    app.MainLoop()

.



Relevant Pages

  • Newbie wxPython questions.
    ... BAsed on the tute in the getting started wiki I created a panel that ... close the app. ... I have attempted to place this on teh frame by ... def EvtCheckBox: ...
    (comp.lang.python)
  • ogl example question
    ... the ogl example from wxpython and it works fine in spe but when I call ... directory within its own frame window. ... def OnInit: ... def OnSizingEndDragLeft(self, pt, x, y, keys, attch): ...
    (comp.lang.python)
  • wxPython; adding a grid to a panel
    ... I am trying to build a frame which will display a wx.grid and a number ... possible to place a grid in a box sizer or on a wx.Panel so that it can ... def GetNumberRows: ...
    (comp.lang.python)
  • problems getting os.system and wxmenu to read options from a file and then execute
    ... # based on a frame, ... idtool = 400 ... # Set up the overall frame verically - text edit window above ... def OnAbout: ...
    (comp.lang.python)
  • Re: wxPython; adding a grid to a panel
    ... I am trying to build a frame which will display a wx.grid and a number ... of other widgets ... possible to place a grid in a box sizer or on a wx.Panel so that it can ... def GetNumberRows: ...
    (comp.lang.python)