class LoginWindow: def __init__(self, master): self.master = master self.master.title("BL 製造表單點檢系統") self.master.geometry("300x250+400+250") self.master.resizable(0, 0) self.username = tk.StringVar() self.password = tk.StringVar() tk.Label(self.master, text="賬號").grid(row=0, column=0, padx=5, pady=5) tk.Entry(self.master, textvariable=self.username).grid(row=0, column=1, padx=5, pady=5) tk.Label(self.master, text="密碼").grid(row=1, column=0, padx=5, pady=5) tk.Entry(self.master, textvariable=self.password, show="*").grid(row=1, column=1, padx=5, pady=5) tk.Button(self.master, text="確認", command=self.login).grid(row=2, column=0, columnspan=2, padx=5, pady=5) def login(self): if self.username.get() == "smt" and self.password.get() == "bl": self.master.destroy() root = tk.Tk() app = ExcelApp(root) root.mainloop() else: messagebox.showwarning("Invalid Credentials", "密碼或賬號錯誤.")將這段代碼的窗口優化得更美觀一些
时间: 2024-04-28 07:21:05 浏览: 100
class LoginWindow:
def __init__(self, master):
self.master = master
self.master.title("BL 製造表單點檢系統")
self.master.geometry("300x250+400+250")
self.master.resizable(0, 0)
self.username = tk.StringVar()
self.password = tk.StringVar()
tk.Label(self.master, text="賬號").grid(row=0, column=0, padx=5, pady=5)
tk.Entry(self.master, textvariable=self.username, width=20).grid(row=0, column=1, padx=5, pady=5)
tk.Label(self.master, text="密碼").grid(row=1, column=0, padx=5, pady=5)
tk.Entry(self.master, textvariable=self.password, show="*", width=20).grid(row=1, column=1, padx=5, pady=5)
tk.Button(self.master, text="確認", command=self.login, width=20, bg="#4CAF50", fg="white").grid(row=2, column=0, columnspan=2, padx=5, pady=5)
def login(self):
if self.username.get() == "smt" and self.password.get() == "bl":
self.master.destroy()
root = tk.Tk()
app = ExcelApp(root)
root.mainloop()
else:
messagebox.showwarning("Invalid Credentials", "密碼或賬號錯誤.")
# 更改了输入框的宽度和按钮的颜色和宽度,使界面更美观
阅读全文