import sys
#带入系统
from PyQt5.QtWidgets import *
from PyQt5.QtCore import QPoint
class winc(QMainWindow):
def __init__(self,parent=None):
super(winc,self).__init__(parent)
#初始化
self.setWindowTitle('显示位置')
self.resize(600,600)
self.rcenter()
#获取状态栏
def rcenter(self):
# 获取屏幕坐标
screen = QDesktopWidget().screenGeometry()
#获取窗口坐标
size =self.geometry()
newleft = (screen.width()- size.width())/2
newtop =(screen.height()-size.height())/2
self.move(int(newleft),int(newtop))
if __name__ =="__main__":
qapp = QApplication(sys.argv)
main = winc()
x1 = QPoint()
main.show()
x1 = main.pos()
print(x1.x(),x1.y())
sys.exit(qapp.exec_())