import tkinter
# # 创建一个窗体
import tkinter.messagebox
# #按钮事件
def btn_click():
if e.get() == '123456':
tkinter.messagebox.showinfo(title='tips', message='bingo')
else:
tkinter.messagebox.showerror(title='tips', message='error')
main = tkinter.Tk()
# # 设置标题
main.title('Hello tkinter')
# # 设置大小(宽x高)
main.geometry('300x200')
# #Label(标签)控件,显示控件
l = tkinter.Label(main, text='Input some text')
l.config(bg='red')
l.config(fg='white')
l.config(height=2)
l.config(width=20)
l.pack()
e = tkinter.Entry(main)
e.insert(0,'000')
e.pack()
# #Button(按钮)
b = tkinter.Button(main,text='OK')
b.config(bg='green')
b.config(command=btn_click)
b.pack()
# # 进入消息循环,让窗口可以不断刷新
main.mainloop()
08-14
200
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)