Maya Spotlight



I just started using sublime text, and I love the ability to quickly open files by pressing ctrl+p and typing in an auto complete text field. So fast! Mac os also has this with the spotlight feature. Here’s a version I wrote for Maya using PyQt. Just press ctrl+p and start typing. It will search a cached index of your project directory for all .ma/.mb files and auto complete. It prioritizes files that you open more often. It also detects files with versioning and puts the latest version on top. I use a QSplashScreen with a little transparency which I fit to the Maya main window to create a sexy overlay.

download here

Comments

  1. joe says:

    I ended up doing what you said with a bit of research 🙂

    Tnks again

  2. joe says:

    hey, tnks a lot for the reply.

    Can you give me an idea how to put the resulting code that i have above and connect the window to a pyqt one with Screemsplash proprieties?

    I do have pyqt installed, i just cant connect it to my modelEditor 🙁

    Thanks

    • joe says:

      I forgot something that may be simple to acomplish my script.

      I have that ui file like this:

      Qt::NonModal

      true

      I see that I can update this mannually, its possible to put here the code for frameless window? something like:

      “self.setWindowFlags(Qt.Tool | Qt.FramelessWindowHint)”

      what’s the sintax for this in xml/ui file? if its possible at all 🙂 tnks again

  3. joe says:

    Hey, great post, I have a question for you. I want to make this a splashscreen and incorporate a modelEditor there. Is it possible? Have a look at my code and tell me if it’s possible to make this “normal window” into a splashscreen since i cant remove the frame from the window just using this code(setWindowFlags(Qt.Tool | Qt.FramelessWindowHint))

    Thank you in advance

    (My .ui file is just an empty widget named “QWdgt”.)

    import maya.cmds as cmds

    if ( cmds.window(‘QWdgt’, exists=True) ):
    cmds.deleteUI(dialog1)

    dialog1 = cmds.loadUI(f=’C:/Users/Anderson/Documents/sample4.ui’)

    form = cmds.formLayout( parent = “QWdgt”)
    myeditor = cmds.modelEditor(“CustomModelEditor”, parent = form )

    cmds.formLayout(form, e=True, af=[(myeditor,’left’,0),
    (myeditor,’right’,0),
    (myeditor,’top’,0),
    (myeditor,’bottom’,0)])

    cmds.showWindow(dialog1)

    • Danny Wynne says:

      Thanks for checking out my blog. If you want to do this, youll need to be using PyQt, not cmds. maya.cmds only has a simple interface to qt (the c++ framework maya’s ui is built on). So to do cool things like the splash screen and embedding widgets where ever you want, you need to install PyQt and get the pointer to the model editor. You can get PyQt files at Nathan Horne’s blog here. And to convert a maya ui element, check out this post.

      hope that helps!

  4. Vlad says:

    Great work, Danny!

    I have simple question: is it possible to keep QSplashScreen widget on screen, even on mouse click or lost focus?

    Thank you in advance!

    • Danny Wynne says:

      sure, if you remove the code here:
      self.le.focusOut.connect(self.hide)
      it should stay visible. But it will probably be annoying to have it stay open like that, so in a maya python script tab, you can hide the tool again with:
      sp.spotlight.hide()
      and change its position with:
      sp.spotlight.setGeometry(X, Y, WIDTH,HEIGHT)

      what are you trying to achieve? Maybe I can adjust the script to suit your needs,
      cheers,

      • Vlad says:

        Hi, Danny!

        The reason is very simple: I am using similar way (based on QSplashScreen) to make my windows in Maya dark in time of running their script.

        Idea is:

        Call Exporter UI;
        Hit “Export”;
        Exporter UI going dark with clock icon;
        Export finished;
        Splashscreen disappeared and Exporter UI in original view.

        The problem is: as soon as we loosing focus (for example, user hit something in Maya viewport) – then SplashScreen disappearing 🙁

        Do you have ani ideas how to keep SplashScreen on?

        Thank you!

        • Danny Wynne says:

          oh yea, the best way is to turn a widget into a splash screen with setWindowFlags(QtCore.Qt.SplashScreen)
          I didn’t realize before that the QSplashScreen vanishes so easily by default.
          heres an example, hope it helps!

          
          from PyQt4 import QtGui, QtCore
          import sip
          import maya.OpenMayaUI as mui
          
          class ExampleSplashWidget(QtGui.QWidget):
            def __init__(self, parent = None):
              super(QtGui.QWidget, self).__init__(parent)
              geo=parent.geometry()
              self.setGeometry(geo)
              self.setWindowFlags(QtCore.Qt.SplashScreen)
              self.setWindowOpacity(.5)
              
          def maya_window():
            ptr = mui.MQtUtil.mainWindow()
            return sip.wrapinstance(long(ptr), QtCore.QObject)
            
          splash = ExampleSplashWidget(maya_window())
          splash.show()
          #splash.hide()
          

  5. Zeth Willie says:

    Very cool, Danny. I just started using Sublime also. Love it (except for not being able to show invisible characters). I’m going to start getting spoiled if this feature isn’t in every program I use from now on:)
    Thanks!

    Z

Leave a Reply

Your email address will not be published.