Windows MDI / Toolbar oddity

If you create a toolbar in a MDIParentFrame, and then set the Position of any MDIChildFrame, that Position will end up being offset by the same amount as the height of the toolbar.

See this demo:

{{{
import wx

app = wx.App(False)
mf = wx.MDIParentFrame(None, -1, "Main Frame")
mf.Size = (400,300)

tb = None
# uncomment this line and cf's top will be Position[1] + tb.Position[1]
#tb = mf.CreateToolBar()

cf = wx.MDIChildFrame(mf)
cf.Size = (200,100)
cf.Position = (50,0)
mf.Show()
cf.Show()

if tb:
  print "Toolbar height:", tb.Size[1]
print "cf top:", cf.Position[1]

app.MainLoop()
}}}

The child frame gets placed at (50,0) as expected. Now, uncomment the creation of the toolbar, and the child frame gets placed at (50,28) leaving a gap between the bottom of the toolbar and the child frame.

There must be code somewhere that assumes we need to account for the toolbar height when in fact we don't?

Paul

Paul McNett wrote:

If you create a toolbar in a MDIParentFrame, and then set the Position of any MDIChildFrame, that Position will end up being offset by the same amount as the height of the toolbar.

See this demo:

{{{
import wx

app = wx.App(False)
mf = wx.MDIParentFrame(None, -1, "Main Frame")
mf.Size = (400,300)

tb = None
# uncomment this line and cf's top will be Position[1] + tb.Position[1]
#tb = mf.CreateToolBar()

cf = wx.MDIChildFrame(mf)
cf.Size = (200,100)
cf.Position = (50,0)
mf.Show()
cf.Show()

if tb:
    print "Toolbar height:", tb.Size[1]
print "cf top:", cf.Position[1]

app.MainLoop()
}}}

The child frame gets placed at (50,0) as expected. Now, uncomment the creation of the toolbar, and the child frame gets placed at (50,28) leaving a gap between the bottom of the toolbar and the child frame.

This bug has been around for a long time, but I'm not sure if a ticket has been created for it or not. You may want to search for it at trac.wxwidgets.org and create a bug report if you can't find one there already.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!