Skip to content
Related Articles
Open in App
Not now

Related Articles

wxPython – Add image with menuitem in wx.MenuBar

Improve Article
Save Article
  • Last Updated : 04 Jun, 2020
Improve Article
Save Article

In this article we are going to learn that how can we add a bitmap image with the menuitem associated with the menu present in menubar object of wx.MenuBar class.

Steps :
1. Create a menubar object of wx.MenuBar class.
2. Create a menu object of wx.Menu class.
3. Create a MenuItem using wx.MenuItem class.
4. Use SetBitmap() function to add bitmap image with menu item.

Syntax of SetBitmap() method: wx.MenuItem.SetBitmap(self, bitmap, checked=True)

Parameters of SetBitmap() method:

Parameter Input Type Description
bmp wx.Bitmap Bitmap we need to use with menuitem.
checked bool If checkable set to True else False.
Code Example:

import wx
class Example(wx.Frame):
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        menubar = wx.MenuBar()
        fileMenu = wx.Menu()
        qmi = wx.MenuItem(fileMenu, APP_EXIT, '&Quit\tCtrl + Q')
        self.Bind(wx.EVT_MENU, self.OnQuit, id = APP_EXIT)
        menubar.Append(fileMenu, '&File')
        self.SetSize((350, 250))
        self.SetTitle('Icons and shortcuts')
    def OnQuit(self, e):
def main():
    app = wx.App()
    ex = Example(None)
if __name__ == '__main__':


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!