EVT_MENU_OPEN breaks EVT_UPDATE_UI

Hi,

This appears to be a bug - binding EVT_MENU_OPEN will break
EVT_UPDATE_UI. The code below is a sample demonstrating the issue.
I've tested this on both Windows XP and Ubuntu 9.10 and neither work.

In evt_idle I purposely set the update event to False to disable the
menu, but as you can see, it comes through enabled. Commenting out the
call to bind EVT_MENU_OPEN fixes this. I'm going to open a TRAC case
but also thought I'd post here in case it's one of those strange "by
design" platform issues

#!/usr/bin/python

import wx

class GUI(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent)
        self.make_menu()
        self.make_toolbar()
        self.do_bindings()

        # comment out the bind to see how it causes my problem
        self.Bind(wx.EVT_MENU_OPEN, lambda x: x)
        self.SetExtraStyle(wx.WS_EX_PROCESS_UI_UPDATES)

    def make_menu(self):
        menu = wx.MenuBar()
        edit = wx.Menu()
        edit.Append(wx.ID_UNDO, "Undo")
        edit.Append(wx.ID_REDO, "Redo")
        menu.Append(edit, "Edit")
        self.SetMenuBar(menu)

    def make_toolbar(self):
        self.toolbar = self.CreateToolBar()

        ids = [wx.ID_UNDO, wx.ID_REDO]
        arts = [wx.ART_UNDO, wx.ART_REDO]

        for _id, art_id in zip(ids, arts):
            art = wx.ArtProvider.GetBitmap(art_id, wx.ART_TOOLBAR)
            self.toolbar.AddSimpleTool(_id, art)
        self.toolbar.Realize()

    def do_bindings(self):
        self.Bind(wx.EVT_UPDATE_UI, self.update_menus, id=wx.ID_UNDO)
        self.Bind(wx.EVT_UPDATE_UI, self.update_menus, id=wx.ID_REDO)

    def update_menus(self, event):
        event.Enable(False)

···

#------------------------------------------

app = wx.App()
frame = GUI(None)
frame.Show()
app.MainLoop()

Did you try using evt.Skip()?

-Matthias

···

Am 12.07.2010, 12:19 Uhr, schrieb Steven Sproat <sproaty@gmail.com>:

Hi,

This appears to be a bug - binding EVT_MENU_OPEN will break
EVT_UPDATE_UI. The code below is a sample demonstrating the issue.
I've tested this on both Windows XP and Ubuntu 9.10 and neither work.

Cheers, that fixed it and now I feel silly :slight_smile:

···

On 12 July 2010 11:58, Matthias <nitrogenycs@googlemail.com> wrote:

Am 12.07.2010, 12:19 Uhr, schrieb Steven Sproat <sproaty@gmail.com>:

Hi,

This appears to be a bug - binding EVT_MENU_OPEN will break
EVT_UPDATE_UI. The code below is a sample demonstrating the issue.
I've tested this on both Windows XP and Ubuntu 9.10 and neither work.

Did you try using evt.Skip()?

-Matthias