ParthJadhav / Tkinter-Designer

An easy and fast way to create a Python GUI 🐍
BSD 3-Clause "New" or "Revised" License
8.96k stars 821 forks source link

FR: Add centering to the window #194

Open omar2205 opened 2 years ago

omar2205 commented 2 years ago

Add this code to the generated code to center the window


w = 320
h = 249

screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()

x = int((screen_width / 2) - (w / 2))
y = int((screen_height / 2) - (h / 2))

window.geometry(f'{w}x{h}+{x}+{y}')
ParthJadhav commented 2 years ago

Hey, Thanks @omar2205 for the code. I'll leave this issue open if someone wants to center their window.