简易登录系统窗口的制作
import time from tkinter import * from tkinter import messagebox class Application(Frame): def __init__(self, master=None): super().__init__(master) self.master = master self.pack() self.creatWidget() def creatWidget(self): self.Label01 = Label(self, text='用户名') self.Label01.pack() v1 = StringVar() self.entry01 = Entry(self, textvariable=v1) self.entry01.pack() self.Label02 = Label(self, text='密码') self.Label02.pack() v2 = StringVar() self.entry02 = Entry(self, textvariable=v2, show="*") self.entry02.pack() Button(self, text="登录", command=self.login).pack() def login(self): username = self.entry01.get() pwd = self.entry02.get() print("数据库比对,用户名和密码正确") print("用户名:"+username) print("密码:" +pwd) print("登录时间:"+str(time.time())) if username=="123456" and pwd=="123456": messagebox.showinfo("xx登录系统", "登录成功!") else: messagebox.showinfo("xx登录系统","用户名或密码错误!") if __name__=='__main__': root = Tk() root.geometry("400x130+300+200") app = Application(master=root) root.mainloop()