Thursday, September 4, 2025
HomeLanguageswxPython – Check() function in wx.MenuItem

wxPython – Check() function in wx.MenuItem

In this article we are going to learn about Check function associated with the wx.MenuItem class of wxPython. As the name Check suggests Check() function checks or unchecks the menu item(ITEM_CHECK). Note that this only works when the item is already appended to a menu.

Syntax: wx.MenuItem.Check(self, check=True) Parameters :

Parameter Input Type Description
check bool Set to True if checked else False.

Code Example: 

Python3




import wx
 
 
class Example(wx.Frame):
 
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
 
        self.InitUI()
 
    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, '&Check', kind = wx.ITEM_CHECK)
        self.fileMenu.Append(self.item)
 
        # Check function checks the item at the first place you open the app
        self.item.Check(check = True)
        self.menubar.Append(self.fileMenu, '&File')
        self.SetMenuBar(self.menubar)
 
        self.SetSize((350, 250))
        self.SetTitle('Icons and shortcuts')
        self.Centre()
 
 
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
 
 
if __name__ == '__main__':
    main()


Output:

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6632 POSTS0 COMMENTS
Nicole Veronica
11800 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11860 POSTS0 COMMENTS
Shaida Kate Naidoo
6749 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6698 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS