I am making a weather app and the window always appears in random places on the screen, how can I choose where the window appears every time?
I tried using this: root.geometry(‘250×150+0+0’) where the first two parameters are the width and height of the window. The last two parameters are x and y screen coordinates. I tried to find the exact coordinates of the center of the screen, but it was not working.
>Solution :
you can use this to center your Tkinter window.
w = 400 # width for the Tk root
h = 600 # height for the Tk root
# get screen width and height
ws = app.winfo_screenwidth() # width of the screen
hs = app.winfo_screenheight() # height of the screen
# calculate x and y coordinates for the Tk root window
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)
# set the dimensions of the screen
# and where it is placed
app.geometry('%dx%d+%d+%d' % (w, h, x, y))