tkinter python – place() a widget to the top-right corner

I am trying to place() my widget on the top-right corner of the window

I can’t use pack() or grid() here.. (due to some reasons)

Answer

Use relx and rely (not necessary for this case, could also use y) and set the anchor to 'ne' (north east – top right):

from tkinter import Tk, Label


root = Tk()

lbl = Label(root, text='Hello World')
lbl.place(relx=1, rely=0, anchor='ne')

root.mainloop()

It basically positions the top right corner of the widget to a relative (relative to its master) x of 1 which basically is the right side of the window and y to 0 which is top. Basically the top-right corner of the widget is placed in the top-right corner of the window