#๐ Grid doesn't work
41 messages ยท Page 1 of 1 (latest)
@faint hearth
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
What ever row/column I want it to bi it just places itselfe in the top left corner
@idle cove
Hmm
Even idk that tbh it works if you add others
Iirc
I usually just use pack so idk
Kk thx for trying
This is because tkinter is smart enough to know that there isn't anything in the other rows/columns so it compacts them. Same thing happens when you run the code on desktop.
Well what are you trying to accomplish? Just having a bunch of empty space around the label?
Why not use padding then?
from tkinter import *
root = Tk()
my_label = Label(root, text="Hello")
my_label.grid(row=0, column=0, padx=20, pady=20)
my_button = Button(root, text="Click me")
my_button.grid(row=1, column=0, padx=20, pady=20)
input_field = Entry(root)
input_field.grid(row=2, column=0, padx=20, pady=20)
root.mainloop()
As long as you understand the code it creates. But if you're still learning how everything works in tkinter I wouldn't learn that way.
Are you trying to center this stuff?
You need to set the column expander
You can set column and row weights, or you can use sticky= for this
Isn't not specifying sticky centering by default though?
Use rowconfigure and columnconfigure and set weights. I think it forces rescaling as well as (re)poistioning
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.
