Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

wxPython – SetValue() 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 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 SetValue() method associated with wx.RadioButton class of wxPython. SetValue() method sets the radio button to checked or unchecked status.  This does not cause a wxEVT_RADIOBUTTON event to get emitted. If the radio button belongs to a radio group exactly one button in the group may be checked and so this method can be only called with value set to True. To uncheck a radio button in a group you must check another button in the same group.

 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. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Syntax:  wx.RadioButton.SetValue(self, value)


ParameterInput TypeDescription
valueboolTrue to check, False to uncheck.



# importing wx library
import wx
# create a 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):
        # parent panel for radio buttons
        self.pnl = wx.Panel(self)
        # create radio buttons
        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))
        # set value for the second radio button as true(checked)
# main function
def main():
  # create an App object
  app = wx.App()
  # create an Example object
  ex = Example(None)
  # running a app
# Driver code
if __name__ == '__main__':
  # main function call


Radio Button


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!