Adding system menu items to wxPython / wxWidgets

How can one add menu items to the system frame menu in wxPython / wxWidgets?
(I'm talking about the menu that appears when you click on an application icon in Windows - the one that is combined, maximized, closed, ...).

I want to add a separate menu item for a simple application that doesn't require a full exploded top menu.

A Windows-only solution, if it exists (and simple enough), would also be helpful.

0


a source to share


1 answer


I don't think wxWidgets / wxPython allows you to control the system menu, with a few exceptions that are not enough for what you want:

  • You can remove the system menu by passing the style flag to wx.Frame: style=wx.DEFAULT_FRAME_STYLE & ~wx.SYSTEM_MENU

  • In Mac OS X, menu items with identifiers such as wx.ID_EXIT

    and wx.ID_HELP

    are moved to the application menu.



I tried to bind the event wx.EVT_MENU_OPEN

and although the event handler is being called, the passed event does not contain anything useful on Windows. The code below displays "None 0" when I open the Frame system menu:

import wx

class Frame(wx.Frame):
    def __init__(self, *args, **kwargs):
        super(Frame, self).__init__(*args, **kwargs)
        self.Bind(wx.EVT_MENU_OPEN, self.onMenuOpen)

    def onMenuOpen(self, event):
        print event.GetMenu(), event.GetMenuId()
        event.Skip()


app = wx.App(0)
frame = Frame(None)
frame.Show()
app.MainLoop()

      

+1


a source







All Articles