Skip to content
Related Articles

Related Articles

wxPython – GetValue() method in wx.RadioButton
  • Last Updated : 01 Aug, 2020

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, maintainablity 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

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing wx library
import wx
  
APP_EXIT = 1
  
# create a 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 a parent panel for radio buttons
        self.pnl = wx.Panel(self)
  
        # create a radio buttons in frame
        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))
  
        # change value of second button to True
        self.rb2.SetValue(True)
          
        # print values of radio buttons True
        # if checked, False otherwise
        print(self.rb1.GetValue())
        print(self.rb2.GetValue())
        print(self.rb3.GetValue())
  
# main function
def main():
    
      # create a App object
    app = wx.App()
    # create a Example object
    ex = Example(None)
      
    ex.Show()
      
    # running a app
    app.MainLoop()
  
# Driver code
if __name__ == '__main__':
    
  # main function call
  main()

chevron_right


Output: 
 

False
True
False

Radio Buttons

 

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :