我最近开始研究密码银行项目。在过去的几天里,它运行良好,但是它的GUI最近停止了工作,我真的不记得我在代码中所做的更改。本质上,tkinter的小部件的宽度似乎受到某些限制。这是一些屏幕截图。
这是我为这些GUI编写的代码。
# Main Menu
passRoot = tk.Tk()
passRoot.configure(bg=Global.LIGHT_COLOR)
passRoot.title("EGPB Main Password")
passRoot.geometry("600x300")
passRoot.resizable(False, False)
passRoot.protocol("WM_DELETE_WINDOW", lambda: sys.exit())
tk.Label(passRoot, bg=Global.LIGHT_COLOR, text="EGPB Password Bank", font=("Roboto Mono", 18, "bold")).place(anchor="center", x=300, y=20)
tk.Label(passRoot, bg=Global.LIGHT_COLOR, text="Insert Your Main Password", font=("Roboto Mono", 10)).place(anchor="center", x=300, y=75)
inp = tk.Entry(passRoot, font=("Roboto Mono", 10), width=30, show="*", bd=2, relief=tk.GROOVE, justify=tk.CENTER)
inp.place(anchor="center", x=300, y=150)
tk.Button(passRoot, bg=Global.MAIN_COLOR, text="OK", width=8, font=("Roboto Mono", 14), command=lambda: self.validatePassword(inp, passRoot)).place(anchor="center", x=300, y=250)
passRoot.mainloop()
# New Entry
root = tk.Tk()
root.configure(bg=Global.LIGHT_COLOR)
root.geometry("600x600")
root.resizable(False, False)
root.title("Add Entry")
tk.Label(root, bg=Global.LIGHT_COLOR, text="Adding a New Entry", font=("", 18)).place(anchor="center", x=300, y=20)
tk.Label(root, bg=Global.LIGHT_COLOR, text="Name", font=("Roboto Mono", 10)).place(anchor="center", x=300, y=75)
name = tk.Entry(root, font=("Roboto Mono", 10), width=45, bd=2, relief=tk.GROOVE, justify=tk.CENTER)
name.place(anchor="center", x=300, y=100)
tk.Label(root, bg=Global.LIGHT_COLOR, text="Password", font=("Roboto Mono", 10)).place(anchor="center", x=300, y=150)
password = tk.Entry(root, font=("Roboto Mono", 10), width=45, bd=2, relief=tk.GROOVE, justify=tk.CENTER)
password.place(anchor="center", x=300, y=175)
tk.Button(root, bg=Global.MAIN_COLOR, text="Generate\nPassword", font=("Roboto Mono", 10), command=lambda: self.generatePassword(password, root)).place(anchor="center", x=525, y=175)
tk.Label(root, bg=Global.LIGHT_COLOR, text="Email (Optional)", font=("Roboto Mono", 10)).place(anchor="center", x=300, y=225)
email = tk.Entry(root, font=("Roboto Mono", 10), width=45, bd=2, relief=tk.GROOVE, justify=tk.CENTER)
email.place(anchor="center", x=300, y=250)
tk.Label(root, bg=Global.LIGHT_COLOR, text="Site (Optional)", font=("Roboto Mono", 10)).place(anchor="center", x=300, y=300)
site = tk.Entry(root, font=("Roboto Mono", 10), width=45, bd=2, relief=tk.GROOVE, justify=tk.CENTER)
site.place(anchor="center", x=300, y=325)
tk.Label(root, bg=Global.LIGHT_COLOR, text="Username (Optional)", font=("Roboto Mono", 10)).place(anchor="center", x=300, y=375)
username = tk.Entry(root, font=("Roboto Mono", 10), width=45, bd=2, relief=tk.GROOVE, justify=tk.CENTER)
username.place(anchor="center", x=300, y=400)
tk.Label(root, bg=Global.LIGHT_COLOR, text="Notes (Optional)", font=("Roboto Mono", 10)).place(anchor="center", x=300, y=450)
note = tk.Entry(root, font=("Roboto Mono", 10), width=45, bd=2, relief=tk.GROOVE, justify=tk.CENTER)
note.place(anchor="center", x=300, y=475)
btn = tk.Button(root, bg=Global.MAIN_COLOR, width=8, text="OK", font=("Roboto Mono", 14), command=lambda: self.addEntry(name.get(), password.get(), root, email.get(), site.get(), username.get(), note.get()))
btn.place(anchor="center", x=300, y=550)
如果您知道我做错了什么以及如何解决它,我将非常感激。
非常感谢您
答案 0 :(得分:0)
.place(relx = 0,depend = 0.05,relheight = 0.03,relwidth = 1)!!使用0-1.0而不是像素可以完全正确缩放它们,尤其是relheight,relwidth,它们是相对的!