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
import wx
APP_EXIT = 1
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 )
self .rb = wx.RadioButton()
self .rb.Create( self .pnl, id = 1 ,
label = "Radio" ,
pos = ( 20 , 20 ))
self .rb.SetBackgroundColour(( 0 , 0 ,
255 , 255 ))
self .rb.SetForegroundColour(( 255 , 255 ,
255 , 255 ))
v = self .rb.GetClassDefaultAttributes()
print (v.colBg)
print (v.colFg)
def main():
app = wx.App()
ex = Example( None )
ex.Show()
app.MainLoop()
if __name__ = = '__main__' :
main()
|
Output:
(0,0,255,255, 255)
(255, 255, 255, 255)
Last Updated :
01 Aug, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...