Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PyQt4.QtGui import *
- from PyQt4.QtCore import *
- ## This would go in some a function after the window is created
- ## Perhaps using a one-shot-timer at the end of the windows __init__()
- ## ex: QTimer.singleShot(0, self.centerWindow)
- # screen geometry
- screen = QDesktopWidget().screenGeometry()
- # mainwindow geometry
- appsize = self.geometry()
- # horizontal center
- hpos = (screen.width() - appsize.width()) / 2
- # vertical center
- vpos = (screen.height() - appsize.height()) / 2
- # move main window to center
- self.move(hpos, vpos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement