Maya Python: Make Maya transparent

Make Maya’s main window transparent (PyQt/PySide)

Makes the entire window transparent (if you found a way to only make the viewport transparent let me know!).
This can be used for modeling with reference on the background (dekstop).


PySide

from PySide import QtGui
import shiboken
import maya.OpenMayaUI as mui

def get_maya_window():
        """Get the maya main window as a QMainWindow instance"""
        ptr = mui.MQtUtil.mainWindow()
        return shiboken.wrapInstance(long(ptr), QtGui.QWidget)

maya_window = get_maya_window()
maya_window.setWindowOpacity(0.6)

PyQt

from PyQt import QtGui
import sip
import maya.OpenMayaUI as mui

def get_maya_window():
        """Get the maya main window as a QMainWindow instance"""
        ptr = mui.MQtUtil.mainWindow()
        return sip.wrapinstance(long(ptr), QtGui.QWidget)

maya_window = get_maya_window()
maya_window.setWindowOpacity(0.6)
Tagged , ,

4 thoughts on “Maya Python: Make Maya transparent

  1. Lucky900 says:

    Hi. Jos
    https://m.youtube.com/watch?v=re4cNARpUQk
    This video can turn one view.

  2. hans says:

    How do i make opacity with only select window?. for example, when I click in graph editor, outline turn on opacity(0.9), when I click outline my graph editor turn on opacity(0.9) (also main interface turn on turn on opacity(0.9).

    or.

    when I click cam view my other perspective view turn on opacity(0.9),

  3. Joakim says:

    Hi man, thx for the tips!, but if I want to do this to a custom window, like a window that I created my self, do you know how to do that? :)

    • Jos says:
      from PySide import QtGui, QtCore
      import shiboken
      import maya.OpenMayaUI as mui
      
      def get_maya_window():
              """Get the maya main window as a QMainWindow instance"""
              ptr = mui.MQtUtil.mainWindow()
              return shiboken.wrapInstance(long(ptr), QtGui.QWidget)
              
      class SampleWindow(QtGui.QWidget):    
          def __init__(self, *args, **kwargs):        
              super(SampleWindow, self).__init__(*args, **kwargs)
              
              # Parent widget under Maya main window        
              self.setParent(get_maya_window())        
              self.setWindowFlags(QtCore.Qt.Window)
              
              # Set the window opacity   
              self.setWindowOpacity(0.6)
         
              self.setGeometry(50, 50, 250, 150)        
                    
      w = SampleWindow()
      w.show()
      

Leave a Reply to Joakim Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>