Search code examples
pythonpymelmaya-api

Trasnparent Window in Maya 2017


i found a script by SAFRONOV 3D (on youtube) that allows him to make the graph editor transparent inside Maya... The problem is that it works on Maya 2014 and i'm Trying to update it to 2017.

I know very little of opne maya and all that, i´m a beginner in pymel and some help would be great. What's Wrong? :

import maya.cmds as cmds
import maya.OpenMayaUI as mui
import shiboken2
import maya.mel as mel
from PySide2 import QtGui
mel.eval('GraphEditor')

def getGraphEditor():
    ptr2 = mui.MQtUtil.findLayout("graphEditor1Window|TearOffPane")
    return shiboken2.wrapInstance(long(ptr2), QtGui.QWidget)

graphEditor = getGraphEditor()
graphEditor.setWindowOpacity(0.5)

def ref(value):
    graphEditor.setWindowOpacity(value)

cmds.floatSlider(p="graphEditor1Window|TearOffPane|graphEditor", min = 0.1 , max = 1.0, v = 0.7, dc = lambda x:ref(x))

Solution

  • Here is my updated script:

    import maya.cmds as cmds
    import maya.OpenMayaUI as mui
    from PySide2 import QtWidgets
    import shiboken2
    
    if cmds.window("GEW", exists=True): cmds.deleteUI("GEW", window=True) 
    cmds.window( "GEW", title="Graph Editor +" )
    cmds.paneLayout( configuration='single' )
    cmds.scriptedPanel( type='graphEditor' )
    cmds.columnLayout (adj=1)
    cmds.floatSlider(min=0.1, max=1.0, v=0.7, dc=lambda x:ref(x))
    cmds.showWindow("GEW")
    
    GEQ = shiboken2.wrapInstance(long(mui.MQtUtil.findWindow( "GEW" )), QtWidgets.QWidget)
    def ref(value): GEQ.setWindowOpacity(value)
    GEQ.setWindowOpacity(0.7)