wxPython – Create Radio Button using Create() function

Create() function is used for the two-step construction of Radio Button in wxPython. Create() function takes different attributes of radio button as an argument

Syntax:  wx.RadioButton.Create(parent, id=ID_ANY, label=””, pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, name=RadioButtonNameStr )

Parameters: 
 

Parameter Input Type Description
parent wx.Window Parent window. Should not be None.
id wx.WindowID Control identifier. A value of -1 denotes a default value.
label string Text Label.
pos wx.Point Window position.
size wx.Window Window size.
style long Window style.
validator wx.Validator Window validator.
name string Window name.

Example: 

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing wx library
import wx
  
APP_EXIT = 1
  
# create an 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 parent panel in frame for radio button
        self.pnl = wx.Panel(self)
  
        # initialize radio button
        self.rb = wx.RadioButton()
  
        # create radio button with two step creation
        self.rb.Create(self.pnl, id = 1,
                       label = "Radio",
                       pos = (20,20))
  
# main function
def main():
    
  # create an App object
  app = wx.App()
  # create an Example object
  ex = Example(None)
    
  ex.Show()
    
  # running an app
  app.MainLoop()
  
# Driver code
if __name__ == '__main__':
    
  # main function call
  main()

chevron_right


Output: 

Radio button in wxpython




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.