Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Tkinter Widgets';宽度弄乱了_Python_User Interface_Tkinter - Fatal编程技术网

Python Tkinter Widgets';宽度弄乱了

Python Tkinter Widgets';宽度弄乱了,python,user-interface,tkinter,Python,User Interface,Tkinter,我最近开始做一个密码银行项目。它在过去几天工作得很好,但是它的GUI最近停止工作了,我真的不记得我在代码中做了什么更改。本质上,tkinter的小部件的宽度似乎受到某种限制。这里有一些截图 下面是我为这些GUI编写的代码 # Main Menu passRoot = tk.Tk() passRoot.configure(bg=Global.LIGHT_COLOR) passRoot.title("EGPB Main Password") passRoo

我最近开始做一个密码银行项目。它在过去几天工作得很好,但是它的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()


如果你们中有人知道我做错了什么,以及如何改正,我将不胜感激

非常感谢

.place(relx=0,rely=0.05,relheight=0.03,relwidth=1)!!使用0-1.0而不是像素完全正确地缩放它们,特别是relheight、relwidth,它们是相对的

阅读
    # 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)