小李设计一个显示加、减、乘、除的单选框界面,代码如下:
import tkinter from tkinter import * root = Tk() v = IntVar() calcs = [ ('+', 1), ('-', 2), ("*", 3), ("/", 4),] for calc, num in calcs: # 设置单选框,用来显示运算符 Radiobutton(text = calc,variable =v,value=num).grid(row=num-1, column=1) root.mainloop()
运行后的界面是?