python对口升学 习题中的常见tkinter对话框
提示:以下是本篇文章正文内容,下面案例可供参考
一、加减乘除
import tkinter as t
def f():
a=t1.get()+x.get()+t2.get()
a=eval(a)
t3.delete(0,"end")
t3.insert(0,a)
top=t.Tk()
top.geometry("400x300")
top.resizable(height=False,width=False)
top.title("加减乘除")
t1=t.Entry(top,font=(20))
t1.pack()
t2=t.Entry(top,font=(20))
t2.pack()
t3=t.Entry(top,font=(20))
t3.pack()
x=t.StringVar()
t.Radiobutton(top,text="加",variable=x,value="+").pack()
t.Radiobutton(top,text="减",variable=x,value="-").pack()
t.Radiobutton(top,text="乘",variable=x,value="*").pack()
t.Radiobutton(top,text="除",variable=x,value="/").pack()
c1=t.Button(top