python 3和tkinter中的单选按钮

python 3和tkinter中的单选按钮,python,tkinter,Python,Tkinter,我用Python3和Tkinter编写了一个程序,它使用单选按钮。现在,如何确保某些单选按钮已被选中?您希望在单选按钮上使用select方法,如下所示: import tkinter as tk root = tk.Tk() root.title("Radio Button Example") button = tk.Radiobutton(root) # Make a radio button button.pack() # Pack it to the screen butto

我用Python3和Tkinter编写了一个程序,它使用单选按钮。现在,如何确保某些单选按钮已被选中?

您希望在单选按钮上使用select方法,如下所示:

import tkinter as tk

root = tk.Tk()
root.title("Radio Button Example")    
button = tk.Radiobutton(root)  # Make a radio button
button.pack()  # Pack it to the screen
button.select()  #This is the bit that makes it checked
root.mainloop()
有关tk中单选按钮的更多信息,请查看本页的教程要点:


您想使用单选按钮上的选择方法,如下所示:

import tkinter as tk

root = tk.Tk()
root.title("Radio Button Example")    
button = tk.Radiobutton(root)  # Make a radio button
button.pack()  # Pack it to the screen
button.select()  #This is the bit that makes it checked
root.mainloop()
有关tk中单选按钮的更多信息,请查看本页的教程要点: