赞
踩
目录
python中tkinter使用Radiobutton组件实现单选按钮,实现选择题并给出判断结果
python中tkinter使用Radiobutton组件实现单选按钮,实现选择题并给出判断结果
- import tkinter as tk
- from tkinter import messagebox
-
- # 提交按钮的点击事件处理函数
- def check_answers():
- # 检查选项是否正确
- if var.get() == 1:
- messagebox.showinfo("结果", "选项A是正确的!")
- else:
- messagebox.showinfo("结果", "选项A是错误的!")
-
-
- # 创建主窗口
- root = tk.Tk()
-
-
- # 创建题目和选项
- question_label = tk.Label(root, text="以下哪个是最大的城市?", font=("Arial", 16))
- question_label.pack()
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。