无论我指定的行或列如何,此脚本中定义的按钮和标签都保留在左上角。谁能给我一个提示为什么?谢谢你的时间。
## Login Script
from tkinter import *
import hashlib
class Login:
def __init__(self,master):
## Create frame
self.frame = Frame(master)
self.frame.grid()
self.frame.grid_columnconfigure(3, weight=4)
self.frame.grid_rowconfigure(3, weight=4)
print(self.frame.grid_size())
## Create Login
username_label = Label(self.frame,text="Username:")
username_label.grid(row=0,column=2,columnspan=2)
self.username = Entry(self.frame)
self.username.grid(row=1,column=2,columnspan=2)
self.username.focus_set()
def main():
root = Tk()
root.geometry("600x400+400+150")
app = Login(root)
root.mainloop()
main()