Hello,
finally I could dulicate the bug, mentioned earlier a few days ago.
wxPython Unicode 2.8.1.1 on Ubuntu Edgy 6.10
To duplicate:
(first the submenu is created)
- choose: toggle submenu (submenu is empty)
- choose: toggle submenu (submenu is here again)
- choose: toggle submenu (submenu is empty) AND traceback:
Is that a bug?
Can I get this working using another approach?
If not: Is there any workaround in the meantime?
Big Problem is:
I get a segmentation fault in DrPython, when I quit the application,
if this critical error is not produced during the run, then quit the
application is ok (no segmenation fault)
In this sample, no segmentation fault happens, even if ther is the critical error befor (?).
How can I get this working?
Under Windows Xp, it is ok (wxPython 2.8.1.1 Unicode)
I would be grateful, please help!
# Small Sample shows a bug (?) in wxPython 2.8.1.1 Unicode on Gtk (Ubuntu Edgy 6.10
# Franz Steinhaeusler, 11.02.2007:
# usage:
# first the submenu is created
# toggle submenu (submenu is empty)
# toggle submenu (submenu is here again)
# toggle submenu (submenu is empty) AND traceback:
···
#
#>python -u "Menu_Sample_Remove.py"
#GTK Accessibility Module initialized
#
#** (python:7724): CRITICAL **: gail_menu_item_ref_child: assertion `(i >= 0)' failed
#
#=====================================================================================
#
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title)
menuBar = wx.MenuBar()
menu1 = wx.Menu()
item = wx.MenuItem(menu1, 500, "&Item Check", "", wx.ITEM_CHECK)
item.SetBitmaps(wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_TOOLBAR, (16,16)),
wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_TOOLBAR, (16,16)))
menu1.AppendItem(item)
self.submenu = wx.Menu()
item = wx.MenuItem (menu1, 501, "Sub", "", subMenu = self.submenu)
item.SetBitmap(wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_TOOLBAR, (16,16)))
menu1.AppendItem (item)
item = wx.MenuItem(menu1, 502, "&Toggle Submenu", "", wx.ITEM_CHECK)
menu1.AppendItem (item)
menuBar.Append(menu1, "&Fun")
self.Bind(wx.EVT_MENU, self.OnMenuSelect, id=502)
self.OnMenuSelect(None)
self.SetMenuBar(menuBar)
def OnMenuSelect(self, event):
mnuitems = self.submenu.GetMenuItems()
num = len(mnuitems)
x = 0
if num == 0:
self.submenu.Append(700, "test1")
self.submenu.Append(701, "test2")
else:
while (x < num):
self.submenu.Remove(700+x)
x = x + 1
app = wx.App(0)
win = MyFrame(None, title="Small Menu Sample, wxPython Version: " + wx.VERSION_STRING + " " +\
["ansi", "unicode"] [wx.USE_UNICODE])
win.Show()
app.MainLoop()
--
Franz Steinhaeusler