On Tue, Jun 19, 2018 at 2:12 PM Zhen Huang <[email protected]> wrote:

> Hi ,
>
> It's there a solution to get maya UI position in screen space .
>
> ''' UI
> import maya.cmds as mc
> mc.window()
> mc.columnLayout(adj = 1)
> mc.button('testButton')
> mc.shwWindow()
>
> '''
>
> There is a discussion about the windows UI in screen space .
> http://discourse.techart.online/t/maya-screen-position-of-gui/3055/6
>
> And I tried it for a button UI , it seems a local position under the
> layout :
> '''
> import maya.OpentMayaUI as mui
> from PySide2 import QtWdigets
> import shiboken2
> prt = mui.MQtUtil.findControl('testButton')
> qwidget = shiboken2.wrapInstance(long(ptr) , QtWidgets.QWdiget)
> print qwidget.x()
> print qwidget.y()
> '''
>
>
You are almost there. The x()/y() are local coordinates relative to its
parent. You can get the position and map it to global (screen coordinates):

qwidget.mapToGlobal(qwidget.pos())


Justin



>
> Thanks ,
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/9029d150-4e98-4f10-b91b-c0939a3efe11%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/9029d150-4e98-4f10-b91b-c0939a3efe11%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA34GVxux%3D-dvR_Z1vybpEEVEP6j83OX1p2vT_jmyehdVg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to