Skip to content
Related Articles
Get the best out of our app
Open App

Related Articles

wxPython – GetClassDefaultAttributes() in wx.RadioButton

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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)


Parameter Input Type Description
variant WindowVariant Variant for Radio Button.

Return Type:  wx.VisualAttributes

Code : 


# importing wx library
import wx
# create an Example class
class Example(wx.Frame):
    # constructor
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs)
        # method calling
    # 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 foreground colour
# main function
def main():
  # create an App object
  app = wx.App()
  # create an Example object
  ex = Example(None)
  # running an app
# Driver code
if __name__ == '__main__':
  # main function call


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

My Personal Notes arrow_drop_up
Last Updated : 01 Aug, 2020
Like Article
Save Article
Similar Reads
Related Tutorials