How can I chage the position of the origin of coordinates to the top left corner?

Question:

My program is a timer. It contains alabel,an entry and abutton. When the user has entered time and clicks on the button, I want the window to move to the top right corner. For this, I use this command:

root.geometry("500x100")
root.geometry("+{}+0".format(root.winfo_screenwidth()-500))

But it does not work correctly. And I get this position:
enter image description here

However when I use the half of width to place it in the top right corner

root.geometry("500x100")
root.geometry("+{}+0".format(root.winfo_screenwidth()-250))

It works correctly.
enter image description here
This means that the origin of coordinates is placed in the middle of window.

How can I chage the position of the origin of coordinates to the top left corner?

Here is the full code of the program:

import customtkinter as ctk
import time

def click_but():
    TimeEntry.pack_forget()
    StartButton.pack_forget()
    hours = int(TimeEntry.get()[:2])
    minutes = int(TimeEntry.get()[3:5])
    seconds = int(TimeEntry.get()[6:])
    root.overrideredirect(True)
    root.geometry("500x100")
    root.geometry("+{}+0".format(root.winfo_screenwidth()-250))
    while hours >= 0 and minutes >= 0 and seconds >= 0:
        TimeLabel.configure(text=(str(hours) if hours >= 10 else ('0' + str(hours))) + ':' + (str(minutes) if minutes >= 10 else ('0' + str(minutes))) + ':' + (str(seconds) if seconds >= 10 else ('0' + str(seconds))))
        TimeLabel.update()
        seconds -= 1
        if seconds < 0:
            seconds = 59
            minutes -= 1
            if minutes < 0:
                minutes = 59
                hours -= 1
                if hours < 0:
                    break
        time.sleep(1)

    root.geometry("500x250")
    TimeEntry.pack(side='top')
    StartButton.pack(side='top', pady = 10)
    root.overrideredirect(False)


root = ctk.CTk()
root.geometry("500x250")


TimeLabel = ctk.CTkLabel(master=root, text='00:00:00', font=('Segue UI', 100))
TimeLabel.pack(side='top')
TimeEntry = ctk.CTkEntry(master=root, font=('Segue UI', 50), width = 300, justify = "center")
TimeEntry.pack(side='top')
StartButton = ctk.CTkButton(master=root, text='Start', command=click_but, font=('Segue UI', 50))
StartButton.pack(side='top', pady = 10)

root.mainloop()

Answers:

I want the window to move to the top right corner.

You can use a - instead of + to have the positions relative to the right and bottom of the screen. Top-right is specified as "-0+0".

You can find the complete definition of what geometry accepts in the tcl/tk documentation for the wm command.

Answered By: Bryan Oakley