
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am working in Pyside. Every time I re-open the window it pops back to the middle of the screen. How can I get either Maya or Windows to remember the position and size?
Here is some basic code I am working with:
import traceback
from PySide import QtCore
from PySide import QtGui
from shiboken import wrapInstance
import maya.cmds as cmds
import maya.OpenMayaUI as omui
import pymel.core as pm
import maya.cmds as cmds
def maya_main_window():
'''
Return the Maya main window widget as a Python object
'''
main_window_ptr = omui.MQtUtil.mainWindow()
return wrapInstance(long(main_window_ptr), QtGui.QWidget)
class TestTool(QtGui.QDialog):
def __init__(self, parent=maya_main_window()):
super(TestTool, self).__init__(parent)
self.qtSignal = QtCore.Signal()
#################################################################
def create(self):
'''
Set up the UI prior to display
'''
self.setWindowTitle("Test")
self.setWindowFlags(QtCore.Qt.Tool)
#self.resize(400, 250) # re-size the window
self.setGeometry(650, 200, 600, 300)
self.setFixedHeight(580)
self.setFixedWidth(300)
QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))
if __name__ == "__main__":
try:
ui.deleteLater()
except:
pass
ui = TestTool()
try:
ui.create()
ui.show()
except:
ui.deleteLater()
traceback.print_exc()
Solved! Go to Solution.