Wednesday, June 10, 2026
HomeLanguageswxPython – GetClassDefaultAttributes() in wx.RadioButton

wxPython – GetClassDefaultAttributes() in wx.RadioButton

Python provides wxpython package which allows us to create a highly functional graphical user interface. It is implemented as a set of extension modules that wrap the GUI components of the wxWidgets library which is written in C++. It is a cross-platform GUI toolkit for python, Phoenix version Phoenix is the improved next-generation wxPython and it mainly focused on speed, maintainability, and extensibility. 

In this article, we are going to learn about GetClassDefaultAttributes() function associated with wx.RadioButton class of wxPython. GetClassDefaultAttributes() function is used to return wx.VisualAttributes object for properties like background color, foreground color, and font associated with the Radio button.
 

Syntax:  wx.RadioButton.GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)

Parameters: 
 

Parameter Input Type Description
variant WindowVariant Variant for Radio Button.

Return Type:  wx.VisualAttributes
 

Code : 
 

Python3




# importing wx library
import wx
  
APP_EXIT = 1
  
# create an Example class
class Example(wx.Frame):
    # constructor
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
  
        # method calling
        self.InitUI()
      
    # method for user interface creation
    def InitUI(self):
  
        # create parent panel for radio buttons
        self.pnl = wx.Panel(self)
  
  
        # create radio button 
        self.rb = wx.RadioButton()
        self.rb.Create(self.pnl, id = 1 ,
                       label = "Radio",
                       pos = (20,20))
  
        # set background colour to blue
        self.rb.SetBackgroundColour((0, 0
                                     255, 255))
        # set foreground colour to white
        self.rb.SetForegroundColour((255, 255,
                                     255, 255))
  
        # create wx.VisualAttributes object
        v = self.rb.GetClassDefaultAttributes()
  
        # print background colour
        print(v.colBg)
        # print foreground colour
        print(v.colFg)
  
# main function
def main():
  # create an App object
  app = wx.App()
    
  # create an Example object
  ex = Example(None)
  ex.Show()
    
  # running an app
  app.MainLoop()
  
# Driver code
if __name__ == '__main__':
    
  # main function call
  main()


Output: 

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

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6896 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS