import tkinter
window=tkinter.Tk()
window.title("汉字占格_作者:韩志华")
window.geometry("405x500+100+100") #中间为小写英文字母x
im=tkinter.PhotoImage(file="e:\python\mi.png",)
tkinter.Label(window,text="国",font=("楷体",230),width=400,height=400,image=im,compound="center").grid(row=0,column=0)
hanzi=tkinter.Entry(font=("楷体",20),width=10)
# hanzi.grid() #这种是左侧对齐
hanzi.grid(row=1,column=0) #这是居中对齐
def getuser():
user=hanzi.get() #获取文本框内容
tkinter.Label(window,text=user[0],font=("楷体",230), width=400,height=400,image=im,compound="center").grid(row=0,column=0)
hanzi.delete(0)
# hanzi.grid(row=1, column=0) # 这是居中对齐
# hanzi=tkinter.Entry(window,text="",font=("楷体", 20), width=8)
# hanzi.grid(row=1, column=0)
tkinter.Button(text="生成汉字占格",font=("楷体",12),command=getuser,height=2).grid(row=2,column=0)
#主循环,循环显示,不关闭窗口
window.mainloop() |