Hi Robin,
Thank you very much for your reply…
To answer your question…I am using XRCed to generate the Python and I am aware of it ‘expecting’ the xrc file to be in the current working directory, however I’m still getting problems with the menubar…
For the moment I have just dropped the menu bar from the xrc file and left it until later and I hand-mod the generated python module to add ./gui/ to the filename (understanding that this defeats the purpose of generating that module).
Having done this everything works fine (minus the menubar) and the forms all behave nicely. By the way… I am sub-classing all of the classes in the generated python module.
I have tried including the menubar as part of the main frame and also having it external to the main frame and adding it to the main frame at run-time but it does not matter what I do I always end up with some variation on the following exception:
···
Traceback (most recent call last):
File “C:\Users\Rob\Eclipse\Workspace\Quiver\src\Main.py”, line 26, in
app = QuiverApp()
File “C:\Users\Rob\Eclipse\Workspace\Quiver\src\Main.py”, line 16, in init
wx.App.init(self, redirect=False)
File “C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx_core.py”, line 7978, in init
self._BootstrapApp()
File “C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx_core.py”, line 7552, in _BootstrapApp
return core.PyApp__BootstrapApp(*args, **kwargs)
File “C:\Users\Rob\Eclipse\Workspace\Quiver\src\Main.py”, line 20, in OnInit
QuiverFrm = frmQuiver()
File “C:\Users\Rob\Eclipse\Workspace\Quiver\src\gui\Forms.py”, line 18, in init
self.SetMenuBar(mnbQuiver())
File “C:\Users\Rob\Eclipse\Workspace\Quiver\src\gui\Forms.py”, line 60, in init
xrcmnbQuiver.init(self)
File “C:\Users\Rob\Eclipse\Workspace\Quiver\src\gui\Quiver_xrc.py”, line 222, in init
self.mnuFile = self.FindItemById(xrc.XRCID(“mnuFile”)).GetSubMenu()
AttributeError: ‘NoneType’ object has no attribute ‘GetSubMenu’
20:31:57: Debug: …\include\wx/msw/private.h(697): ‘UnregisterClass’ failed with error 0x00000584 (class still has open windows.).
It does not matter whether I have the xrc, xcfg and generated module in the current working directory or my ./gui/ directory. I always seem to end up with a ‘NoneType’ object has no attribute ‘GetSubMenu’ error.
The offending line of code from the menu bar class is:
self.mnuFile = self.FindItemById(xrc.XRCID(“mnuFile”)).GetSubMenu()
from the code snippet below…
class xrcmnbQuiver(wx.MenuBar):
def init(self):
pre = get_resources().LoadMenuBar(“mnbQuiver”)
self.PostCreate(pre)
Define variables for the menu items
idx = self.FindMenu(“New”)
if idx != wx.NOT_FOUND:
self.mnuFile = self.GetMenu(idx)
else:
self.mnuFile = self.FindItemById(xrc.XRCID(“mnuFile”)).GetSubMenu()
self.mniNew = self.FindItemById(xrc.XRCID(“mniNew”))
Whilst I would prefer to have the XRCed generated module and associated files in a folder of my choosing the problem is that I can’t even make it work in the current working directory.
Curiously, it did work in one version of my code (curses for not keeping a GIT or SVN repository) but when it stopped working, all I did was and another panel to the xrc file. I actually did not touch the menu bar.
Anyway…thank you once again for taking the time to look at my problem and if there is anything else you can suggest I would be most grateful.
Regards
Rob M