wxPython – GetValue() method in wx.RadioButton
Last Updated :
29 Oct, 2021
Python provides wxpython package which allows us to create high functional graphical user interface. It is 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 GetValue() method associated with wx.RadioButton class of wxPython. GetValue() function is used to returns True if the radio button is checked, False otherwise.
GetValue() function needs no arguments.
Syntax: wx.RadioButton.GetValue(self)
Parameters: GetValue() function needs no arguments.
Return : return True if the radio button is checked, False otherwise
Example:
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 .rb1 = wx.RadioButton( self .pnl,
label = 'Button 1' ,
pos = ( 30 , 10 ))
self .rb2 = wx.RadioButton( self .pnl,
label = 'Button 2' ,
pos = ( 30 , 30 ))
self .rb3 = wx.RadioButton( self .pnl,
label = 'Button 3' ,
pos = ( 30 , 50 ))
self .rb2.SetValue( True )
print ( self .rb1.GetValue())
print ( self .rb2.GetValue())
print ( self .rb3.GetValue())
def main():
app = wx.App()
ex = Example( None )
ex.Show()
app.MainLoop()
if __name__ = = '__main__' :
main()
|
Output:
False
True
False
Radio Buttons
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...