You can use this library to center your Tkinter or PyQt windows both horizontally and vertically. That means your window will show in the middle of the screen.
pip install centerit
or
Clone the repository using
git clone https://github.com/MrinmoyHaloi/centerit
or download as a zip file and extract it.
import everything from the library using
from centerit import *
Then Call centertk for Tkinter
centertk(root, width, height)
and centerqt for PyQt5
centerqt(root, width, height)
You just have to pass the root window name and the dimensions you want for your root window.
I used python 3.9.5 to develop it. I used windows 10 20H2 and parrot OS 4.11.1 (Debian Based) to test it. I would appreciate if anyone tests it out with other versions of python that are lower than 3.9.2. I will try to add support for other gui libraries in the future, like wxPython, PyQt4, PySide2 etc.