zl程序教程

您现在的位置是:首页 >  后端

当前栏目

python 的 Tkinter实现一个简易计算器详解编程语言

Python编程语言 实现 详解 一个 简易 计算器 tkinter
2023-06-13 09:20:23 时间
frame.pack() Button(frame, text="1",command=lambda: callback(1) ).grid(row=0,column=0) Button(frame, text="2",command=lambda: callback(2) ).grid(row=0,column=1) Button(frame, text="3",command=lambda: callback(3) ).grid(row=0,column=2) Button(frame, text="4",command=lambda: callback(4) ).grid(row=1,column=0) Button(frame, text="5",command=lambda: callback(5) ).grid(row=1,column=1) Button(frame, text="6",command=lambda: callback(6) ).grid(row=1,column=2) Button(frame, text="7",command=lambda: callback(7) ).grid(row=2,column=0) Button(frame, text="8",command=lambda: callback(8) ).grid(row=2,column=1) Button(frame, text="9",command=lambda: callback(9) ).grid(row=2,column=2) Button(frame, text="0",command=lambda: callback(0) ).grid(row=3,column=0) Button(frame, text="+",command=lambda: callback1("+") ).grid(row=3,column=1) Button(frame, text="-",command=lambda: callback1("-") ).grid(row=3,column=2) Button(frame, text="*",command=lambda: callback1("*") ).grid(row=4,column=1) Button(frame, text="/",command=lambda: callback1("/") ).grid(row=4,column=2) Button(frame, text="=", command=self.say_hi).grid(row=4,column=0) w = Label(frame1,text="输入结果") w.pack() self.e = Entry(frame1) self.e.pack(padx=5) w1 = Label(frame1,text="计算结果") w1.pack() v = StringVar() e1 = Entry(frame1, textvariable=v) v.set("") self.v = v e1.pack() def say_hi(self): print "hi there, everyone!",self.e.get() input_str = self.e.get() self.v.set(cacl(input_str)) app = App(root) root.mainloop()

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/8151.html

cjavapython