Hi all,
I repost a message I send to the group compt.soft-sys.wxwindows few days ago, since I'm not sure I posted to the right group.
I have a problem using a toolbar in conjunction with aui when loading from
an XRC file. I solved the problem but I'm looking for a better solution.
This is what I have done:
In the XRC file I have a frame with a toolbar and a panel. After loading the
xrc file, I add the toolbar and the panel to the aui manager. But I get a
lot of problems in the toolbar redraw and moving the toobar leave an empty
toolbar space at the top of the window. I tried setting the flag
'dontattachtoframe' but this didn't solve the problem.
I solved in this way: in the xrc file I moved the toolbar from child of
frame to sibling of it. Then I loaded the xrc file and loaded frame and
toolbar separately. In this way the toolbar is working perfectly.
I copy an example in Pyhton that reproduce the problem (I work with Python
2.51 and wxPython 2.8.1.1):
class App(wx.App):
def OnInit(self):
self.res = xrc.XmlResource("./mio.xrc")
#my resource file
self.frame = self.res.LoadFrame(None, 'MainFrame')
self.panel = self.frame.FindWindowByName('Panel')
self.toolbar = self.frame.FindWindowByName('ToolBar')
#toolbar as child of frame
self.float_toolbar = self.res.LoadToolBar(self.frame,
'FloatToolBar') #toolbar as sibling of frame
self._mgr = wx.aui.AuiManager()
self._mgr.SetManagedWindow(self.frame)
self._mgr.AddPane(self.panel,
wx.aui.AuiPaneInfo().Name("Panel").CenterPane())
self._mgr.AddPane(self.toolbar,
wx.aui.AuiPaneInfo().Name("ToolBar").ToolbarPane())
self._mgr.AddPane(self.float_toolbar,
wx.aui.AuiPaneInfo().Name("FloatToolBar").ToolbarPane())
self._mgr.Update()
self.frame.Show()
self.SetTopWindow(self.frame)
return True
....
extracted from my xrc file
<?xml version="1.0" encoding="cp1252"?>
<resource>
<object class="wxFrame" name="MainFrame">
<object class="wxToolBar" name="ToolBar">
<object class="tool">
....some tools....
</object>
<object class="wxPanel" name="Panel">
</object>
<object class="wxToolBar" name="FloatToolBar">
<object class="tool">
......some tools....
</object>
I hope that the formatting is ok.
Commenting out a toolbar or the other it's easy to obtain the problem. Also
working with both toolbar shows that the child toolbar is not working
properly.
Where am I wrong? There's somethign that can I do to have the child toolbar
working? Perhaps I'm missing something, I'm just beginning to work with wx.
Thanks for any answer,
Enrico