[MAYA] Screen position of GUI

Hey there,
I was wondering if anbody knew a way of getting the screep position of a window in Maya?

Problem:
I’m trying to get Maya to remember the screen position (whether dual screen or not) of a window, so when it relaunches the gui, it’ll be in the same exact place.
I know I can use an optionVar to do the job, but I just need to know the screen position to input into the option var.

Thanks in advanced!
Adrian

Unless I’m misunderstanding your question (or you want the data for something else), maya already restores your window’s size and position if you have Preferences -> Interface -> Remember size and position checked. It gets added to prefs/windowPrefs.mel, which you can query with cmds.windowPrefs

If Capper’s suggestion doesn’t work, and you are using >2012, then take a look at this thread about QT positioning:

You should be able to do this from PySide or PyQT.

Continuing with what btribble is talking about, it’s fairly trivial to get the position using Qt.

import maya.OpenMayaUI as apiUI
from PyQt4 import QtCore
import sip

ptr = apiUI.MQtUtil.findControl('go')
qwidget = sip.wrapinstance(long(ptr), QtCore.QObject)
print qwidget.x()
print qwidget.y()

Nathan Horne’s blog has a few useful snippets for interacting with Maya windows using Qt (http://nathanhorne.com/).

[QUOTE=capper;18405]Continuing with what btribble is talking about, it’s fairly trivial to get the position using Qt.

import maya.OpenMayaUI as apiUI
from PyQt4 import QtCore
import sip

ptr = apiUI.MQtUtil.findControl('go')
qwidget = sip.wrapinstance(long(ptr), QtCore.QObject)
print qwidget.x()
print qwidget.y()

Nathan Horne’s blog has a few useful snippets for interacting with Maya windows using Qt (http://nathanhorne.com/).[/QUOTE]

I am ashamed at the inadequacy of my previous post. :wink:

[QUOTE=capper;18405]Continuing with what btribble is talking about, it’s fairly trivial to get the position using Qt.

import maya.OpenMayaUI as apiUI
from PyQt4 import QtCore
import sip

ptr = apiUI.MQtUtil.findControl('go')
qwidget = sip.wrapinstance(long(ptr), QtCore.QObject)
print qwidget.x()
print qwidget.y()

Nathan Horne’s blog has a few useful snippets for interacting with Maya windows using Qt (http://nathanhorne.com/).[/QUOTE]

Does this only work with pyQT windows?
Because when I run it I get:
Error: ‘QObject’ object has no attribute ‘x’

Its wrapped to a QtCore.QObject, try QtGui.QWidget.