wxPython – Create Radio Button using Create() function
Last Updated :
01 Aug, 2020
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
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 .rb = wx.RadioButton()
self .rb.Create( self .pnl, id = 1 ,
label = "Radio" ,
pos = ( 20 , 20 ))
def main():
app = wx.App()
ex = Example( None )
ex.Show()
app.MainLoop()
if __name__ = = '__main__' :
main()
|
Output:
Share your thoughts in the comments
Please Login to comment...