I want to make a widget appear in the center of the screen without using grid or pack.
Here is some example code:
import tkinter
Win=tkinter.Tk()
Welcome=tkinter.Label(Win,text="Welcome.")
Welcome.place(x=Win.winfo_width()//2-Welcome.winfo_width()//2,y=16)
Win.update()
When I ran the code, the widget appeared on the far left of the screen instead of the center. I was told about reqwidth
and update_idletasks
, which fixed the code, but I was wondering if someone could explain why the code doesn't work without reqwidth
and update_idletasks
, as I like to fully understand programming concepts.