- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to center a window on the screen in Tkinter?
In order to place a tkinter window at the center of the screen, we can use the PlaceWindow method in which we can pass the toplevel window as an argument and add it into the center.
We can also set the window to its center programmatically by defining its geometry.
#Import the tkinter library from tkinter import * #Create an instance of tkinter frame win = Tk() #Set the geometry win.geometry("600x250") win.eval('tk::PlaceWindow . center') win.mainloop()
Running the above code will create a centered window.
- Related Articles
- How to center a div on the screen using jQuery?
- How to keep the window focus on the new Toplevel() window in Tkinter?
- How to center a Window in Java?
- How to put a Tkinter window on top of the others?
- How to display full-screen mode on Tkinter?
- How to center a Tkinter widget?
- How do I position the buttons on a Tkinter window?
- Removing the TK icon on a Tkinter window
- Tkinter-How to get the current date to display in a tkinter window?
- How to display a JFrame to the center of a screen in Java?
- How to put a Toplevel window in front of the main window in Tkinter?
- How to get the screen size in Tkinter?
- How to draw images in the Tkinter window?
- How to center a Tkinter widget in a sticky frame?