📜  wxPython - 使用 Create()函数创建单选按钮

📅  最后修改于: 2022-05-13 01:54:51.684000             🧑  作者: Mango

wxPython - 使用 Create()函数创建单选按钮

Create()函数用于wxPython中 Radio Button 的两步构造。 Create()函数将单选按钮的不同属性作为参数

例子:

Python3
# 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()


输出:

wxpython中的单选按钮