I have multiple monitors, and when I try to center the window on the screen, it goes to the left edge of the screen. Code:
def center_window(window, window_width, window_height, offset_x=0, offset_y=0):
s_width = window.winfo_screenwidth()
s_height = window.winfo_screenheight()
x_cordinate = int((s_width/2) - (window_width/2))
y_cordinate = int((s_height/2) - (window_height/2))
window.geometry("{}x{}+{}+{}".format(window_width, window_height, x_cordinate+offset_x, y_cordinate+offset_y))
If I disable a monitor, this doesn't happen, and the window gets centered correctly.
I tried other solutions, as explained in this question: How to center a window on the screen in Tkinter?
None of the answers work with a multiple-monitors setup. By the way I'm on Ubuntu22-04. Thanks for any help, I'll appreciate it.