You can't mix pack
and grid
.
Warning: Never mix grid and pack in the same master window. Tkinter will happily spend the rest of your lifetime trying to negotiate a solution that both managers are happy with. Instead of waiting, kill the application, and take another look at your code. A common mistake is to use the wrong parent for some of the widgets.
I would say to choose the grid
function because it is easier to choose where each widget goes. So, change l1.pack()
to l1.grid(row=0, column=0)
(Replace the 0's with the row and column you want to place it with).
For example:
from tkinter import *
root = Tk()
root.geometry("700x400") # Title
root.title("Dance Admission Form") # Label
l1 = Label(text="Admission Form", font="Arial 15 bold")
l1.grid(row=0, column=0)
user = Label(root, text="Username")
password = Label(root, text="Password")
user.grid(row=1, column=0)
password.grid(row=2, column=0)
root.mainloop()
or a centered version:
from tkinter import *
root = Tk()
root.geometry("700x400") # Title
root.title("Dance Admission Form") # Label
l1 = Label(text="Admission Form", font="Arial 15 bold")
l1.grid(row=0, column=0)
root.columnconfigure(0, weight=1)
user = Label(root, text="Username")
password = Label(root, text="Password")
user.grid(row=1, column=0)
password.grid(row=2, column=0)
root.mainloop()