Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nobolu-ootsuka-unrealengine/9689ae9016da5eeda9f5815164e8e924 to your computer and use it in GitHub Desktop.
Save nobolu-ootsuka-unrealengine/9689ae9016da5eeda9f5815164e8e924 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import os
from functools import partial
import time
import imp
import random
"""
PySide2モジュールを探し、ある場合はそちらをインポートします。
"""
try:
imp.find_module('PySide2')
from PySide2.QtWidgets import *
from PySide2.QtGui import *
from PySide2.QtCore import *
except ImportError:
from PySide.QtGui import *
from PySide.QtCore import *
LOGO_IMAGE = r"画像のパスをここに入れてください。"
def get_maya_pointer():
"""
Mayaのメインウィンドウを取得する関数
"""
try:
import maya.cmds as cmds
from maya import OpenMayaUI
except ImportError:
return None
"""
実は2017ではshibokenも2になっているので、あればshiboken2をインポートします。
"""
try:
imp.find_module("shiboken2")
import shiboken2
return shiboken2.wrapInstance(long(OpenMayaUI.MQtUtil.mainWindow()), QWidget)
except ImportError:
import shiboken
return shiboken.wrapInstance(long(OpenMayaUI.MQtUtil.mainWindow()), QWidget)
from maya.app.general.mayaMixin import MayaQWidgetBaseMixin, MayaQWidgetDockableMixin
#class Example_connectAttr(MayaQWidgetDockableMixin, QScrollArea):
class Example_connectAttr(MayaQWidgetDockableMixin, QMainWindow):
def __init__(self, node=None, *args, **kwargs):
super(Example_connectAttr, self).__init__(*args, **kwargs)
# Member Variables
self.nodeName = node # Node name for the UI
self.attrUI = None # Container widget for the attr UI widgets
self.attrWidgets = {} # Dict key=attrName, value=widget
randomInt=random.randint(0,9999)
self.setObjectName("MyDock_Window"+str(randomInt))
self.setWindowTitle("MyDock Window")
self._initUI()
def _initUI(self):
wrapper = QWidget()
self.setCentralWidget(wrapper)
mainLayout = QVBoxLayout()
wrapper.setLayout(mainLayout)
def start():
maya_win = get_maya_pointer()
ui = Example_connectAttr(node = maya_win)
ui.show(dockable=True, floating=True)
return ui
print("__name__ = "+__name__)
if __name__ == '__main__' or __name__ == "NppMaya" or __name__ == "main":
app = QApplication.instance()
if app is None:
app = QApplication([])
ui = start()
app.exec_()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment