-1

I've recently started working on a Password Bank project. It worked fine for the last few days, but its GUI recently stopped working, and i don't really remember what I changed in the code. Essentially, the tkinter's widgets' width seems restrained by something. Here's some screenshots.

Main Menu

New Entry

And here's the code that i wrote for these pieces of the 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)

I'd be really grateful if any of you knew what I did wrong and how to fix it.

Thank you very much

  • Read [Why are multiple instances of Tk discouraged?](https://stackoverflow.com/a/48045508/7414759) – stovfl Apr 15 '20 at 20:08

1 Answers1

0

.place(relx=0, rely=0.05, relheight=0.03, relwidth=1) !! using 0-1.0 instead of pixels totally scales them properly, especially relheight, relwidth, they are Relative!

rn0mandap
  • 333
  • 1
  • 8