Classe de janela QT para projetar ferramentas para serem compatíveis entre vários programas VFX.
O principal objetivo da classe é se integrar à interface do usuário do programa, mas também contém recursos úteis, como lidar com segurança com retornos de chamada e salvar automaticamente a posição da janela.
O uso pretendido é fazer com que sua classe de janela herde VFXWindow - que é uma instância do QMainWindow . Ao ligar para cls.show() , ele iniciará o tipo de janela correto com base em qual programa é carregado e quais configurações foram salvas anteriormente.
Isso é perfeitamente estável, mas ainda há muito que precisa de melhorias. Qualquer ajuda para estender o suporte ao aplicativo existente ou a adição de novos aplicativos é muito apreciada.
pip install vfxwindow
from Qt import QtWidgets
from vfxwindow import VFXWindow
class MyWindow ( VFXWindow ):
"""Test window to show off some features."""
WindowID = 'vfx.window.test'
WindowName = 'My Window'
WindowDockable = True
def __init__ ( self , parent = None , ** kwargs ):
super ( MyWindow , self ). __init__ ( parent , ** kwargs )
# Setup widgets/build UI here as you normally would
self . setCentralWidget ( QtWidgets . QWidget ())
# Setup callbacks
self . callbacks . add ( 'file.new' , self . afterSceneChange )
self . callbacks . add ( 'file.load' , self . afterSceneChange )
if self . application == 'Maya' : # Maya supports before/after callbacks
self . callbacks . add ( 'file.new.before' , self . beforeSceneChange )
self . callbacks . add ( 'file.load.before' , self . beforeSceneChange )
elif self . application in ( 'Nuke' , 'Substance' ): # Nuke and Painter/Designer support close
self . callbacks . add ( 'file.close' , self . beforeSceneChange )
# Wait until the program is ready before triggering the new scene method
self . deferred ( self . afterSceneChange )
def afterSceneChange ( self , * args ):
"""Create the scene specific callbacks.
These are being created in a callback "group".
Subgroups are also supported.
Even though the callback is the same, the signatures can differ.
See '/vfxwindow/<app>/callbacks.py' for the relevant signatures.
"""
if self . application == 'Maya' :
self . callbacks [ 'scene' ]. add ( 'node.add' , self . mayaNodeAdded , nodeType = 'dependNode' )
if self . application == 'Nuke' :
self . callbacks [ 'scene' ]. add ( 'node.add' , self . nukeNodeAdded )
def beforeSceneChange ( self , * args ):
"""Delete the scene specific callbacks."""
self . callbacks [ 'scene' ]. delete ()
def mayaNodeAdded ( self , node , clientData ):
"""Print out the node that was added in Maya."""
import maya . api . OpenMaya as om2
print ( 'Node was added: {}' . format ( om2 . MFnDependencyNode ( node ). name ()))
def nukeNodeAdded ( self ):
"""Print out the node that was added in Nuke."""
import nuke
node = nuke . thisNode ()
print ( 'Node was added: {}' . format ( node . name () or 'Root' ))
def checkForChanges ( self ):
"""Update the UI if it is has been in a "paused" state.
This is needed for Nuke and Substance Designer/Painter, because
there's no way to detect if the window is closed or just hidden.
For safety all callbacks will get paused, and upon unpausing,
this method will be run to allow the window to correctly update.
"""
self . beforeSceneChange ()
self . afterSceneChange ()
if __name__ == '__main__' :
MyWindow . show ()✔️ Trabalho / ❔ Untroted / não está funcionando
| Janela padrão | Janela ancorada | Retornos de chamada | Versões testadas | Linux | Windows | Macos | |
|---|---|---|---|---|---|---|---|
| Maya | ✔️ | ✔️ | ✔️ | 2011-2016, 2017+ | ✔️ | ✔️ | ❔ |
| Maya (independente) | ✔️ | ✔️ | ❔ | ✔️ | ❔ | ||
| Nuke | ✔️ | ✔️ | ✔️ | 9-14 | ❔ | ✔️ | ❔ |
| Nuke (terminal) | ✔️ | ✔️ | ❔ | ✔️ | ❔ | ||
| Houdini | ✔️ | 16-19 | ✔️ | ✔️ | ❔ | ||
| Motor irreal | ✔️ | 4.19-4.23, 5.0-5.3 | ✔️ | ❔ | |||
| Liquidificador | ✔️ | ✔️ | 2.8-4.2 | ❔ | ✔️ | ❔ | |
| Blender (fundo) | ✔️ | ❔ | 3.1-4.2 | ❔ | ✔️ | ❔ | |
| Katana | ✔️ | 7 | ❔ | ✔️ | ❔ | ||
| 3ds máx | ✔️ | 2018-2020 | ❔ | ✔️ | ❔ | ||
| Pintor de substâncias | ✔️ | ✔️ | ✔️ | 8.3 | ✔️ | ✔️ | ❔ |
| Designer de substâncias | ✔️ | ✔️ | ✔️ | 2019.3, 7.1, 12.3 | ✔️ | ✔️ | ❔ |
| Fusão Blackmagic | ✔️ | 9 | ❔ | ✔️ | ❔ | ||
| CryEngine Sandbox | ✔️ | 5.7 | ❔ | ✔️ | ❔ | ||
| Python independente | ✔️ | 2.7 (qt4), 3.7-3.9 (qt5) | ❔ | ✔️ | ❔ | ||
| Natron | ✔️ | 2.5 | ❔ | ✔️ | ❔ | ||
| Renderdoc | ✔️ | 1.33 | ❔ | ✔️ | ❔ |
* Passe o mouse sobre campos sublinhados para ver quaisquer detalhes/problemas extras.
Certos aplicativos do Windows têm uma interface COM baseada em despacho, o que permitirá um link entre o Python e o aplicativo. Consulte o Photoshop-Scripting-Python para obter um exemplo sobre como se conectar a um aplicativo.
Atualmente, não há como lançar VFXWindow a partir desses aplicativos.