I tried to follow the lesson on databases in this youtube video from freecodecamp. However, when I wrote my code and executed it, an entry box and a label are stuck on top of my button to submit a record. I don't know how to fix this issue.
Using rowconfigure
didn't help either and the label is still stuck on top of the submit button.
Also, for every label and button that I add, even if the button's row is smaller than the label's row, the label is displayed before the button in the GUI.
label and entry box on top of button
I have removed all the database elements from my code as they are not relevant to the problem I am facing. Here is my code:
from tkinter import *
window = Tk()
window.geometry("400x400")
# Create function to Delete a record
def delete():
pass
# create submit function
def submit():
pass
# create query function
def query():
pass
f_name = Entry(window, width=30)
f_name.grid(row=0, column=1, pady=(10, 0))
l_name = Entry(window, width=30)
l_name.grid(row=1, column=1)
address = Entry(window, width=30)
address.grid(row=2, column=1)
city = Entry(window, width=30)
city.grid(row=3, column=1)
province = Entry(window, width=30)
province.grid(row=4, column=1)
p_code = Entry(window, width=30)
p_code.grid(row=5, column=1)
# Create text box label
f_name_label = Label(window, text="First Name")
f_name_label.grid(row=0, column=0, pady=(10, 0))
l_name_label = Label(window, text="Last Name")
l_name_label.grid(row=1, column=0)
address_label = Label(window, text="Street")
address_label.grid(row=2, column=0)
city_label = Label(window, text="City")
city_label.grid(row=3, column=0)
province_label = Label(window, text="Province")
province_label.grid(row=4, column=0)
p_code_label = Label(window, text="Postal Code")
p_code_label.grid(row=5, column=0)
# Create submit button
submit_btn = Button(window, text="Add record to database", command=submit)
submit_btn.grid(rows=6, column=0, columnspan=2, pady=10, padx=10, ipadx=100)
# create a query button
query_btn = Button(window, text="Show Records", command=query)
query_btn.grid(rows=7, column=0, columnspan=2, pady=10, padx=10, ipadx=125)
delete_box = Label(window, text="ID Number")
delete_box.grid(row=8, column=0)
delete_box = Entry(window, width=30)
delete_box.grid(row=8, column=1)
# create a delete button
delete_btn = Button(window, text="Delete Record", command=delete)
delete_btn.grid(rows=9, column=0, columnspan=2, pady=10, padx=10, ipadx=125)
window.mainloop()
What mistake have I made?
Edit: Thanks for the responses. It turns out that it was just a typo (rows
instead of row
) that caused the problem. But now I am curious to know how did my previous code give that particular output? Shouldn't it have thrown an error saying that rows
is an invalid keyword argument? Moreover, when the row
parameter was not even given for submit_btn
, how was it correctly placed below "Postal Code"? Why exactly was there an overlap of the label, entry and button?