Centering CTk() and Tk() windows to the main display (windows 10&11) #1820
HyperNylium
started this conversation in
Showcase
Replies: 4 comments 9 replies
-
Works perfect, thanks! |
Beta Was this translation helpful? Give feedback.
3 replies
-
Funciona Perfeitamente |
Beta Was this translation helpful? Give feedback.
0 replies
-
Do you know how to do this with multiple monitors? Without manually changing some of the values |
Beta Was this translation helpful? Give feedback.
5 replies
-
Apparently, there seems to be some kind of problem. On my 1920x1080 monitor, using practically the same function, I still get abruptly incorrect values. What could it be? def centralize(window_w:int, window_h:int, Screen:ct.CTk) -> str:
print(window_w, window_h)
return "{}x{}+{}+{}".format(
window_w,
window_h,
((Screen.winfo_screenwidth()/2)+(window_w/2)) * Screen._get_window_scaling(),
((Screen.winfo_screenheight()/2)+(window_h/1.5)) * Screen._get_window_scaling()
) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When the CTk() window launches, it launches somewhere on your main display but doesn't really have a center function. I know this is kind of common knowledge by now but just wanted to put this here for anyone that is looking for it:
I originally made the function in tkinter but when i started to use customtkinter, the window wasn't really launching in the middle of the display. It was always offset a little. This new version takes in account for the scale factor of your display as well (100%, 125%, 150%, etc).
This is what the tkinter version looks like:
You may use this code however you like. Modify, distribute, I don't care. Just give some credit is all I ask for ^_^
Beta Was this translation helpful? Give feedback.
All reactions