#grid布局.py
from tkinter import *
root=Tk()
root.title('计算器示例—2022110207002曹仁杰')
root.geometry('300x300+300+300')
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='pink')
L5=Button(root,text='5',width=5,bg='green')
L6=Button(root,text='6',width=5,bg='pink')
L7=Button(root,text='7',width=5,bg='green')
L8=Button(root,text='8',width=5,bg='blue')
L9=Button(root,text='9',width=5,bg='red')
L0=Button(root,text='0',width=5,bg='yellow')
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)