All of my PythonCard samples which have child windows now have a problem on
the Mac with 2.5.1.0p8 that they didn't have with the last preview.
Apparently, there was some change with the Mac menubar handling because if
there is a child window that doesn't have an associated menubar and my code
tries to enable or disable a menu item I get an assertion error. I'm not
entirely sure if this only happens if the child window is "in front" when
the enable/disable is called.
File "//Library/Python/2.3/wx/core.py", line 7578, in Enable
return _core.MenuBar_Enable(*args, **kwargs)
wx.core.PyAssertionError: C++ assertion "wxAssertFailure" failed in
../src/common/menucmn.cpp(892): attempt to enable an item which doesn't
exist
Does anyone have a plain wxPython program where this is easy to see? I don't
want to write a minimal test if we already have other apps with child
windows which exhibit the problem.
I'll copy Stefan on this as I don't think he is on this list.
Kevin Altis wrote:
All of my PythonCard samples which have child windows now have a problem on
the Mac with 2.5.1.0p8 that they didn't have with the last preview.
Apparently, there was some change with the Mac menubar handling because if
there is a child window
Do you mean a frame that is a child of the main frame?
that doesn't have an associated menubar and my code
tries to enable or disable a menu item I get an assertion error. I'm not
entirely sure if this only happens if the child window is "in front" when
the enable/disable is called.
File "//Library/Python/2.3/wx/core.py", line 7578, in Enable
return _core.MenuBar_Enable(*args, **kwargs)
wx.core.PyAssertionError: C++ assertion "wxAssertFailure" failed in
../src/common/menucmn.cpp(892): attempt to enable an item which doesn't
exist
If I understand correctly, you are trying to enable/disable an item on a menubar that is not currently shown, correct?
Stefan, shouldn't this be able to work?
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
I'll copy Stefan on this as I don't think he is on this list.
Kevin Altis wrote:
> All of my PythonCard samples which have child windows now have a problem
on
> the Mac with 2.5.1.0p8 that they didn't have with the last preview.
> Apparently, there was some change with the Mac menubar handling because
if
> there is a child window
Do you mean a frame that is a child of the main frame?
> that doesn't have an associated menubar and my code
> tries to enable or disable a menu item I get an assertion error. I'm not
> entirely sure if this only happens if the child window is "in front"
when
> the enable/disable is called.
>
> File "//Library/Python/2.3/wx/core.py", line 7578, in Enable
> return _core.MenuBar_Enable(*args, **kwargs)
> wx.core.PyAssertionError: C++ assertion "wxAssertFailure" failed in
> ../src/common/menucmn.cpp(892): attempt to enable an item which doesn't
> exist
If I understand correctly, you are trying to enable/disable an item on a
menubar that is not currently shown, correct?
Stefan, shouldn't this be able to work?
As the assert comes from menucmn this is not a mac specific problem, getting
at the right menubar probably is, how does your code look like, perhaps I
can see clearer what's happening then...
I'll copy Stefan on this as I don't think he is on this list.
Kevin Altis wrote:
All of my PythonCard samples which have child windows now have a problem
on
the Mac with 2.5.1.0p8 that they didn't have with the last preview.
Apparently, there was some change with the Mac menubar handling because
if
there is a child window
Do you mean a frame that is a child of the main frame?
that doesn't have an associated menubar and my code
tries to enable or disable a menu item I get an assertion error. I'm not
entirely sure if this only happens if the child window is "in front"
when
the enable/disable is called.
File "//Library/Python/2.3/wx/core.py", line 7578, in Enable
return _core.MenuBar_Enable(*args, **kwargs)
wx.core.PyAssertionError: C++ assertion "wxAssertFailure" failed in
../src/common/menucmn.cpp(892): attempt to enable an item which doesn't
exist
If I understand correctly, you are trying to enable/disable an item on a
menubar that is not currently shown, correct?
Stefan, shouldn't this be able to work?
As the assert comes from menucmn this is not a mac specific problem, getting
at the right menubar probably is, how does your code look like, perhaps I
can see clearer what's happening then...
Well as usual my earlier assumption was wrong about where the bug was which a sample cleared up. It isn't the reference to the menubar that is the problem it is wxMenuBar::FindMenuItem method. As far as I can tell, unless you remove the ampersand from the menu name, then on the Mac the search will always fail and return -1. It doesn't seem to matter if you leave the ampersand in for the menu item name, only the menu. For example, FindMenuItem('File', '&New') and FindMenuItem('File', 'New') are okay on the Mac, but FindMenuItem('&File', 'New') will return -1. FindMenuItem on Windows doesn't have this problem and I'm pretty sure it has always worked on GTK as well. Note that FindMenu does not have a problem with an ampersand in the name and as mentioned previously I don't think this was broke prior to 2.5.1.0p8.
You can fire up the PyShell on the Mac to confirm this.
Note the use of a trailing space on 'New ' because Patrick put a space between New and the \t (tab) followed by the shortcut key on all the menu items in his code. Trailing spaces apparently aren't stripped when the menu items are created, so you have to include that in the FindMenuItem search.
Anyway, I'm glad I dug deeper on the original problem because I finally realized I created the child window menubar issue myself in PythonCard model.py with a workaround I added almost two years ago to make sure a wxFrame had a menubar on the Mac. At the time, I think we were getting bus errors if you didn't do this and there are probably still some weird issues so I just added a check for whether the wxFrame has a parent before creating a menubar and now child windows don't wipe out the parent menubar. Sorry, for the earlier alarm.