{"id":445,"date":"2020-03-10T16:10:42","date_gmt":"2020-03-10T16:10:42","guid":{"rendered":"http:\/\/lotusithub.com\/blog\/?p=445"},"modified":"2022-08-11T11:28:08","modified_gmt":"2022-08-11T11:28:08","slug":"how-to-place-a-python-tkinter-window-in-the-center-of-the-screen-from-tkinter-import","status":"publish","type":"post","link":"https:\/\/lotusithub.com\/blog\/how-to-place-a-python-tkinter-window-in-the-center-of-the-screen-from-tkinter-import\/","title":{"rendered":"How to place a Python tkinter window in the center of the screen from tkinter import"},"content":{"rendered":"<p>&nbsp;<\/p>\n<h1>Python Tkinter window in the center of the screen from tkinter import<\/h1>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">my_window = Tk()<\/span><\/p>\n<p><span style=\"font-weight: 400;\">my_window.title(&#8220;Lotus IT Hub&#8221;)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">width_of_window = 600<\/span><\/p>\n<p><span style=\"font-weight: 400;\">height_of_window = 400<\/span><\/p>\n<p><span style=\"font-weight: 400;\">screen_width = my_window.winfo_screenwidth()<\/span><\/p>\n<p><span style=\"font-weight: 400;\">screen_height = my_window.winfo_screenheight()<\/span><\/p>\n<p><span style=\"font-weight: 400;\">x_coordinate = (screen_width\/2)-(width_of_window\/2)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">y_coordinate = (screen_height\/2)-(height_of_window\/2)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">my_window.geometry(&#8220;%dx%d+%d+%d&#8221; %(width_of_window,height_of_window,x_coordinate,y_coordinate))<\/span><\/p>\n<p><span style=\"font-weight: 400;\">my_window.mainloop()<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Python Tkinter window in the center of the screen from tkinter import &nbsp; &nbsp;&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[136,144],"class_list":["post-445","post","type-post","status-publish","format-standard","hentry","category-python","tag-python-tkinter-window","tag-screen-from-tkinter-import"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/posts\/445","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/comments?post=445"}],"version-history":[{"count":1,"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/posts\/445\/revisions"}],"predecessor-version":[{"id":1753,"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/posts\/445\/revisions\/1753"}],"wp:attachment":[{"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/media?parent=445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/categories?post=445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lotusithub.com\/blog\/wp-json\/wp\/v2\/tags?post=445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}