Skip to content
Related Articles
Open in App
Not now

Related Articles

wxPython – GetBitmap() function in wx.Button

Improve Article
Save Article
Like Article
  • Last Updated : 24 Jun, 2020
Improve Article
Save Article
Like Article

In this article we are going to learn about GetBitmap() function associated with wx.Button class of wxPython. GetBitmap() function is simply used to return the bitmap shown by the button.

The returned bitmap may be invalid only if the button doesn’t show any images

Syntax: wx.Button.GetBitmap(self)

Parameters: No parameters in GetBitmap() function.

Return Type: wx.Bitmap

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)
        # create parent panel for button
        self.pnl = wx.Panel(self)
        # create wx.Bitmap object 
        bmp = wx.Bitmap('pointer.png')
        # create button at point (20, 20) = wx.Button(self.pnl, id = 1, label ="Button", pos =(20, 20),
                                          size =(100, 30),  name ="button")
        # set bmp as bitmap for button
        # get wx.Bitmap object
        bmap =
        # print depth of bitmap
        self.SetSize((350, 250))
def main():
    app = wx.App()
    ex = Example(None)
if __name__ == '__main__':

Console Output:


Output Window:

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!