Skip to content
Snippets Groups Projects
Commit 66b1d7ca authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Sigh. wx.MenuItems really screw things up.

parent 605a9027
No related branches found
No related tags found
No related merge requests found
...@@ -84,27 +84,26 @@ def isWidgetAlive(widget): ...@@ -84,27 +84,26 @@ def isWidgetAlive(widget):
"""Returns ``True`` if the given ``wx.Window`` object is "alive" (i.e. """Returns ``True`` if the given ``wx.Window`` object is "alive" (i.e.
has not been destroyed), ``False`` otherwise. Works in both wxPython has not been destroyed), ``False`` otherwise. Works in both wxPython
and wxPython/Phoenix. and wxPython/Phoenix.
.. warning:: Don't try to test whether a ``wx.MenuItem`` has been
destroyed, as it will probably result in segmentation
faults. Check the parent ``wx.Menu`` instead.
""" """
import wx import wx
if platform.wxFlavour == WX_PHOENIX:
return bool(widget)
elif platform.wxFlavour == WX_PYTHON: if platform.wxFlavour == platform.WX_PHOENIX:
try: excType = RuntimeError
# GetId seems to be available on all wx elif platform.wxFlavour == platform.WX_PYTHON:
# objects, despite not being documented. excType = wx.PyDeadObjectError
#
# I was originally calling IsEnabled, try:
# but this causes segfaults if called widget.GetParent()
# on a wx.MenuItem from within an return True
# event handler on that menu item!
widget.GetId() except excType:
return True return False
except wx.PyDeadObjectError:
return False
class Platform(notifier.Notifier): class Platform(notifier.Notifier):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment