我正在尝试使用 tkinter 中的网格格式制作计算器,但文本字段正在取代按钮。
我是 Python 的初学者,只是卡住了。
这是我的源代码的一部分:
from Tkinter import*
#function for about menu
def about():
win2=Tk()
win2.wm_title("About")
l=Label(win2,text=" CAL-C ver 1.0 \n Developer. \n Mohd Sanad",padx=5,pady=40)
l.pack()
win=Tk()#creating window
win.wm_title("CAL-C")#changing window title
#Initiliazing about menu button
menubar=Menu(win)
menubar.add_command(label="About",command=about)
win.config(menu=menubar)
v=StringVar()
e=Entry(win,textvariable=v)
e.grid(row=0,column=0,columnspan=3,sticky=W+E)
b1=Button(win,text="1")
b2=Button(win,text="2")
b3=Button(win,text="3")
b4=Button(win,text="4")
b5=Button(win,text="5")
b6=Button(win,text="6")
b7=Button(win,text="7")
b8=Button(win,text="8")
b9=Button(win,text="9")
b1.grid(row=1,column=0)
b2.grid(row=1,column=1)
b3.grid(row=1,column=2)
b4.grid(row=2,column=0)
b5.grid(row=2,column=1)
b6.grid(row=2,column=2)
b7.grid(row=3,column=0)
b8.grid(row=3,column=1)
b9.grid(row=3,column=2)