

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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.
Example
#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()
Output
Running the above code will create a centered window.
- Related Questions & Answers
- How to center a popup window on screen using JavaScript?
- How to center a div on the screen using jQuery?
- How to center a Window in Java?
- How to keep the window focus on the new Toplevel() window in Tkinter?
- Removing the TK icon on a Tkinter window
- How to put a Tkinter window on top of the others?
- How to center a Tkinter widget?
- How to display full-screen mode on Tkinter?
- How do I position the buttons on a Tkinter window?
- How to display a JFrame to the center of a screen in Java?
- Align flex items in the center on different screen sizes in Bootstrap
- How to get the screen size in Tkinter?
- Tkinter-How to get the current date to display in a tkinter window?
- Align HTML5 SVG to the center of the screen
- How to put a Toplevel window in front of the main window in Tkinter?
Advertisements