In the last tutorial, we have discussed about the GetLabelText() function of wx.MenuItem class which is one of the important function of this class. Now, in this tutorial, we will discuss about another important function from the wx.MenuItem class of wxPython module i.e., SetBitmap() function.
What is SetBitmap() function?
The SetBitmap() is an important function associated with the wx.MenuItem class of wxPython module. The SetBitmap() function is used to sets the bitmap for the menu item in the menu bar. It must be called before we append the given item with the menu bar associated with it.
It means if we append an item in the menu bar without providing bitmap image in it, then it may be not possible for us to setup a bitmap image later in the menu bar. But we can change or reset the bitmap image from the menu bar if we have given it initially in the function while appending.
Syntax for SetBitmap() function:
Whenever we are using the SetBitmap() function of wxMenuItem class, we have to use the syntax correctly in order to set bitmap image correctly as menu item into the menu bar of GUI. Following is the correct syntax of using the SetBitmap() function of wxPython module in our Python program:
wx.SetBitmap( “bmp”, “Check”)
As we can see in the above given syntax for SetBitmap() function, it takes only two parameters that we have to define properly for execution of SetBitmap() function successfully.
Following are the description of the parameters that must be given in the SetBitmap() function:
- bmp: The bmp is the bitmap image given in the SetBitmap() function. This parameter is used to set the bitmap image for the menu bar. It will add the bitmap image as a menu item in the menu bar.
- checked: The checked is the value given in the SetBitmap() function. The bool value true will be used to check the image given and false value will be assigned to uncheck the image given in the function. It works like enabling or disabling the given image in the menu item of menu bar.
Python: SetBitmap() function in wxPython - Tutorial And Example
In the last tutorial, we have discussed about the GetLabelText() function of wx.MenuItem class which is one of the…
Python program to check whether a given number is prime or not - Tutorial And Example
A positive integer greater than 1 is called a prime number if it is divisible by one and number itself except 1…
Python Program to check whether a given number is Armstrong or not - Tutorial And Example
A number is said to be an Armstrong if the sum of each digit's cube of a given number equals the original number…
Python MySQL Update Operation - Tutorial And Example
Python MySQL Update Operation: In this part of tutorial, we will learn that how can we update a table present in SQL…