代码:
#gidoo布局.py
from tkinter import *
root =Tk()
root.title('计算器示例--2021110201140周志杰')
root.geometry("300x150+280+280")
root.config(bg='#cc66ff')
L1=Button(root,text='1',width=5,bg='yellow')
L2=Button(root,text='2',width=5,bg='red')
L3=Button(root,text='3',width=5,bg='blue')
L4=Button(root,text='4',width=5,bg='green')
L5=Button(root,text='5',width=5,bg='brown')
L6=Button(root,text='6',width=5,bg='purple')
L7=Button(root,text='7',width=5,bg='orange')
L8=Button(root,text='8',width=5,bg='#87cefa')
L9=Button(root,text='9',width=5,bg='white')
L0=Button(root,text='0',width=5,bg='aqua')
Lp=Button(root,text='.',bg='pink')
L1.grid(row=0,column=0)
L2.grid(row=0,column=1)
L3.grid(row=0,column=2)
L4.grid(row=1,column=0)
L5.grid(row=1,column=1)
L6.grid(row=1,column=2)
L7.grid(row=2,column=0)
L8.grid(row=2,column=1)
L9.grid(row=2,column=2)
L0.grid(row=3,column=0,columnspan=2,sticky=E+W)
Lp.grid(row=3,column=2,sticky=E+W)
root.mainloop()