Friday, October 17, 2025
HomeLanguageswxPython – GetClassDefaultAttributes() function in wx.BitmapButton

wxPython – GetClassDefaultAttributes() function in wx.BitmapButton

In this article we are going to learn about GetClassDefaultAttributes() function associated with wx.BitmapButton class of wxPython. GetClassDefaultAttributes() function is used to return wx.VisualAttributes object for properties like background colour, foreground colour and font.
It takes variant as arguments.
 

Syntax: wx.Button.GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)
Parameters: 

Parameter Input Type Description
variant WindowVariant Variant for button.

Return Type: wx.VisualAttributes

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.pnl = wx.Panel(self)
        bmp = wx.Bitmap('right.png')
        self.btn = wx.BitmapButton(self.panel, id = wx.ID_ANY, bitmap = bmp,
                          size =(bmp.GetWidth()+10, bmp.GetHeight()+10))
 
        # wx.VisualAttributes OBJECT
        va = self.btn.GetClassDefaultAttributes(variant = wx.WINDOW_VARIANT_NORMAL)
 
        # PRINT PROPERTIES
        print(va.colBg)
        print(va.colFg)
        print(va.font)
 
        self.SetSize((350, 250))
        self.SetTitle('wx.Button')
        self.Centre()
 
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
 
 
if __name__ == '__main__':
    main()


Console Output: 
 

(240, 240, 240, 255)
(0, 0, 0, 255)

Output Window: 
 

 

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

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS