Skip to content
Related Articles

Related Articles

wxPython – SetBitmap() function in wxPython

View Discussion
Improve Article
Save Article
  • Last Updated : 09 Jun, 2020
View Discussion
Improve Article
Save Article

In this article we are going we are going to learn about SetBitmap() function associated with wx.MenuItem class of wxPython. SetBitmap() sets the bitmap for the menu item. SetBitmap must be called before the item is appended to the menu, i.e. appending the item without a bitmap and setting one later is not guaranteed to work. But the bitmap can be changed or reset later if it had been set up initially.




Parameter Input Type Description
bmp wx.Bitmap Bitmap to set for menu item.
checked bool True to check and False for uncheck.

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)
        self.menubar = wx.MenuBar()
        self.fileMenu = wx.Menu()
        self.item = wx.MenuItem(self.fileMenu, 1, '&Radio', helpString ="Check Help")
        # set bitmap for tool
        self.item.SetBitmap(bmp = wx.Bitmap('right.png'), checked = True)
        self.menubar.Append(self.fileMenu, '&File')
        self.SetSize((350, 250))
        self.SetTitle('Icons and shortcuts')
def main():
    app = wx.App()
    ex = Example(None)
if __name__ == '__main__':

Output Window:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!