How to place a Python tkinter window in the center of the screen from tkinter import

by lotusithub

 

Python Tkinter window in the center of the screen from tkinter import

 

 

my_window = Tk()

my_window.title(“Lotus IT Hub”)

width_of_window = 600

height_of_window = 400

screen_width = my_window.winfo_screenwidth()

screen_height = my_window.winfo_screenheight()

x_coordinate = (screen_width/2)-(width_of_window/2)

y_coordinate = (screen_height/2)-(height_of_window/2)

my_window.geometry(“%dx%d+%d+%d” %(width_of_window,height_of_window,x_coordinate,y_coordinate))

my_window.mainloop()

Related Posts

Leave a Comment