簡體   English   中英

Python 3和Tkinter中的單選按鈕

[英]Radio buttons in python 3 and tkinter

我已經使用Python 3和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中RadioButtons的更多信息,請查看教程上的此頁面:

http://www.tutorialspoint.com/python/tk_radiobutton.htm

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM