class LoginWindow: def __init__(self, master): self.master = master self.master.title("CQ SMT BL 監控平臺-003無紙化點檢系統") self.master.geometry("300x250+400+250") self.master.resizable(0, 0) self.username = tk.StringVar() self.password = tk.StringVar() # 创建一个 Panedwindow,设置 orient 为垂直方向 pw = ttk.Panedwindow(self.master, orient='vertical') pw.pack(fill='both', expand=True) # 创建上面板 top_frame = ttk.Frame(pw, width=300, height=100, relief='sunken') pw.add(top_frame) # 创建下面板 bottom_frame = ttk.Frame(pw, width=300, height=50, relief='sunken') pw.add(bottom_frame) # 在上面板中添加控件 ttk.Label(top_frame, text="賬號:", width=10).grid(row=0, column=0, padx=10, pady=10) ttk.Entry(top_frame, textvariable=self.username, width=20).grid(row=0, column=1, columnspan=1, padx=2, pady=2) ttk.Label(top_frame, text="密碼:", width=10).grid(row=1, column=0, padx=10, pady=10) ttk.Entry(top_frame, textvariable=self.password, show="*", width=20).grid(row=1, column=1, columnspan=1,padx=2, pady=2) # 在下面板中添加控件 style = ttk.Style() style.configure("TButton", background="#4CAF50", foreground="blue", font=("Helvetica", 12), width=10) ttk.Button(bottom_frame, text="確認", command=self.login, style="TButton", width=10).grid(row=0, column=0,columnspan=1, padx=35,pady=10) ttk.Button(bottom_frame, text="取消", command=self.master.destroy, style="TButton", width=10).grid(row=0,column=1,columnspan=1,padx=10,pady=10)將窗口中間那根綫取消掉
时间: 2023-11-25 07:06:54 浏览: 72
要将窗口中间的那根线取消掉,可以在创建 Panedwindow 时设置 sashrelief 参数为 "flat",如下所示:
```
pw = ttk.Panedwindow(self.master, orient='vertical', sashrelief='flat')
```
这样就可以取消掉中间的那根线了。
相关问题
class LoginWindow: def __init__(self, master): self.master = master self.master.title("登录") self.master.geometry("300x300+500+200") self.label_username = tk.Label(self.master, text="用户名") self.label_username.pack() self.entry_username = tk.Entry(self.master) self.entry_username.pack() self.label_password = tk.Label(self.master, text="密码") self.label_password.pack() self.entry_password = tk.Entry(self.master, show="*") self.entry_password.pack() self.button_login = tk.Button(self.master, text="登录", command=self.login,bg="black",fg="white") self.button_login.pack(pady=20) def login(self): # 在这里添加登录验证逻辑 if self.entry_username.get() == username and self.entry_password.get() == password: # 如果验证通过,跳转到 DiaryWindow self.master.destroy() root = tk.Tk() diary_window = DiaryWindow(root) root.mainloop() else: messagebox.showinfo("错误", "用户名或密码错误!")
这是一个 Python 的登录窗口类,它包括一个用户名输入框、一个密码输入框和一个登录按钮。当用户点击登录按钮时,它会调用 login 方法进行登录验证。如果用户名和密码验证通过,它会关闭登录窗口并打开 DiaryWindow 窗口;否则,它会弹出一个错误提示框。需要注意的是,这里的 username 和 password 是需要在代码中设置的变量。
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", "密碼或賬號錯誤.")將這段代碼的窗口優化得更美觀一些
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", "密碼或賬號錯誤.")
# 更改了输入框的宽度和按钮的颜色和宽度,使界面更美观
阅读全文