wxPython – Enable() function in wx.RadioButton

In this article we will learn about Enable() function associated with wx.RadioButton class of wxPython. Enable() function is simply used to enable or disable the Radio Button for user input. It takes a boolean argument True to Enable and False to disable.

Syntax: wx.RadioButton.Enable(self, enable=True)

Parameters:

Parameter Input Type Description
enable bool If True, enables the window for input. If False, disables the window.

Return Type: bool

Returns: True if the window has been enabled or disabled, False if nothing was done, i.e. if the window had already been in the specified state.

Code Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

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)
          
        # create radio button at position (30, 10)
        self.rb1 = wx.RadioButton(self.pnl, label ='Btn1'
                             pos =(30, 10), size =(100, 20))
  
  
        # disable the radio button using Enable() function
        self.rb1.Enable(False)
  
  
def main():
    app = wx.App()
    ex = Example(None)
    ex.Show()
    app.MainLoop()
  
  
if __name__ == '__main__':
    main()

chevron_right


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.