When I open the window, it appears in the upper left hand corner of my desktop. How do I make it open in the center of the FreeCAD application window ?
Thanks
Code: Select all
# import the QtGui via PySide
# FYI, PySide handles Python2 and Python3
from PySide.QtGui import *
# create a new class for this macro
# inherit everything from QWidget
class MyWindow(QWidget):
# init the class - set up our window
def __init__(self):
#initialize the QWidget class for use here
super(MyWindow, self).__init__()
#clear the console message for this run
# App.Console.Clear()
# print a console debug message
App.Console.PrintMessage("\nQWidget initialized\n")
#create a button
self.btnLoad = QPushButton("Load Points")
#connect the clicked method
#self.btnLoad.clicked.connect(self.btnClick)
#create a layout
layout = QVBoxLayout()
#add the button to the layout
layout.addWidget(self.btnLoad)
#add the layout to the window
self.setLayout(layout)
#make the window stay on top
self.setWindowFlags(Qt.WindowStaysOnTopHint)
#center the window
#????
#show the window
self.show()
# create an instance of the new class
# MyWindow.__init__ will run, starting the application
app = MyWindow()