Thursday, October 9, 2025
HomeLanguageswxPython | GetClassDefaultAttributes() function in python

wxPython | GetClassDefaultAttributes() function in python

In this article we are going to learn about GetClassDefaultAttributes() of class wx.ToolBar of wxPython. GetClassDefaultAttributes() is used to return visual attributes of toolbar like background color, foreground color, the font used for control label/text inside it. Parameters :

Parameter Input Type Description
variant windowVariant Variant style of window

Syntax :

wx.ToolBar.GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)

Return Type:

wx.VisualAttributes

Code Example: 

Python3




import wx
 
 
class Example(wx.Frame):
    global count
    count = 0;
 
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
 
        self.InitUI()
 
    def InitUI(self):
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        pnl = wx.Panel(self)
        self.toolbar = self.CreateToolBar()
        # Add Tools Using AddTool function
        rtool = self.toolbar.AddTool(13, 'twoTool', wx.Bitmap('wrong.png'), shortHelp ="Simple Tool2")
 
        self.toolbar.Realize()
        self.SetSize((350, 250))
        self.SetTitle('Control')
        self.Centre()
 
        # get Visual attribute object
        t = self.toolbar.GetClassDefaultAttributes(variant = wx.WINDOW_VARIANT_NORMAL)
        # print background color ratio
        print(t.colBg)
        # print foreground color ratio
        print(t.colFg)
        # print wx.Font object
        print(t.font)
 
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
 
 
if __name__ == '__main__':
    main()


Output:

(240, 240, 240, 255)
(0, 0, 0, 255)
<wx._core.Font object at 0x00000080FC7B5280>
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32342 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6712 POSTS0 COMMENTS
Nicole Veronica
11875 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11937 POSTS0 COMMENTS
Shaida Kate Naidoo
6833 POSTS0 COMMENTS
Ted Musemwa
7092 POSTS0 COMMENTS
Thapelo Manthata
6786 POSTS0 COMMENTS
Umr Jansen
6789 POSTS0 COMMENTS