我正在尝试创建一个表单,并且在首页上询问用户名和密码。我正在使用网格并放置行,但是tkinter并没有获取我想要的行。请在下面找到代码:-
import tkinter as tk
class Passwordchecker(tk.Frame):
def __init__(self, parent):
tk.Frame.__init__(self, parent)
self.parent = parent
self.initialize_user_interface()
def initialize_user_interface(self):
self.parent.resizable(False, False) # This code helps to disable windows from resizing
window_height = 120
window_width = 210
screen_width = self.winfo_screenwidth()
screen_height = self.winfo_screenheight()
x_cordinate = int((screen_width / 2) - (window_width / 2))
y_cordinate = int((screen_height / 2) - (window_height / 2))
self.parent.geometry("{}x{}+{}+{}".format(window_width, window_height, x_cordinate, y_cordinate))
self.parent.title("MN Creater")
self.label = tk.Label(self.parent, text="Username : ")
self.label.grid(row=9, column=0)
self.entry = tk.Entry(self.parent)
self.entry.grid(row=1, column=1)
self.label = tk.Label(self.parent, text="Password : ")
self.label.grid(row=3, column=0)
self.entry = tk.Entry(self.parent)
self.entry.grid(row=3, column=1)
if __name__ == '__main__':
root = tk.Tk()
root.mainloop()
答案 0 :(得分:0)
Tkinter正在“获取”您给它的行。空的行和列的大小为零,因此,无论将其放在第9行还是第9000行,它仍将显示在最后一行的正下方,其中包含某些内容。