本文整理汇总了Python中shiboken.wrapInstance方法的典型用法代码示例。如果您正苦于以下问题:Python shiboken.wrapInstance方法的具体用法?Python shiboken.wrapInstance怎么用?Python shiboken.wrapInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shiboken
的用法示例。
在下文中一共展示了shiboken.wrapInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mayaToQT
# 需要导入模块: import shiboken [as 别名]
# 或者: from shiboken import wrapInstance [as 别名]
def mayaToQT(name):
"""
Maya -> QWidget
:param str name: Maya name of an ui object
:return: QWidget of parsed Maya name
:rtype: QWidget
"""
ptr = OpenMayaUI.MQtUtil.findControl(name)
if ptr is None:
ptr = OpenMayaUI.MQtUtil.findLayout(name)
if ptr is None:
ptr = OpenMayaUI.MQtUtil.findMenuItem(name)
if ptr is not None:
return shiboken.wrapInstance(long(ptr), QWidget)
# ----------------------------------------------------------------------------
示例2: qt_import
# 需要导入模块: import shiboken [as 别名]
# 或者: from shiboken import wrapInstance [as 别名]
def qt_import(shi=False, cui=False):
"""
import pyside/pyQt
Returns:
multi: QtGui, QtCore, QtWidgets, wrapInstance
"""
lookup = ["PySide2", "PySide", "PyQt4"]
preferredBinding = os.environ.get("MGEAR_PYTHON_QT_BINDING", None)
if preferredBinding is not None and preferredBinding in lookup:
lookup.remove(preferredBinding)
lookup.insert(0, preferredBinding)
for binding in lookup:
try:
return _qt_import(binding, shi, cui)
except Exception:
pass
raise _qt_import("ThisBindingSurelyDoesNotExist", False, False)
示例3: getMayaMainWindow
# 需要导入模块: import shiboken [as 别名]
# 或者: from shiboken import wrapInstance [as 别名]
def getMayaMainWindow():
if hasattr(Qt, "IsPySide2"):
if Qt.IsPySide2:
import shiboken2 as shiboken
else:
import shiboken
# Qt version less than 1.0.0
elif hasattr(Qt, "__version_info__"):
if Qt.__version_info__[0] >= 2:
import shiboken2 as shiboken
else:
import shiboken
else:
try:
import shiboken2 as shiboken
except:
import shiboken
return shiboken.wrapInstance(long(OpenMayaUI.MQtUtil_mainWindow()), QtWidgets.QMainWindow)
示例4: get_maya_main_window
# 需要导入模块: import shiboken [as 别名]
# 或者: from shiboken import wrapInstance [as 别名]
def get_maya_main_window():
"""Get the main Maya window as a QtGui.QMainWindow instance
@return: QtGui.QMainWindow instance of the top level Maya windows
ref: https://stackoverflow.com/questions/22331337/how-to-get-maya-main-window-pointer-using-pyside
"""
from anima.ui.lib import QtWidgets, QtCore
from maya import OpenMayaUI
ptr = OpenMayaUI.MQtUtil.mainWindow()
if ptr is not None:
from anima.ui.lib import IS_PYSIDE, IS_PYSIDE2, IS_PYQT4, IS_QTPY
if IS_PYSIDE():
import shiboken
return shiboken.wrapInstance(long(ptr), QtWidgets.QWidget)
elif IS_PYSIDE2():
import shiboken2
return shiboken2.wrapInstance(long(ptr), QtWidgets.QWidget)
elif IS_PYQT4():
import sip
return sip.wrapinstance(long(ptr), QtCore.QObject)
示例5: getDock
# 需要导入模块: import shiboken [as 别名]
# 或者: from shiboken import wrapInstance [as 别名]
def getDock(name='LightingManagerDock'):
"""
This function creates a dock with the given name.
It's an example of how we can mix Maya's UI elements with Qt elements
Args:
name: The name of the dock to create
Returns:
QtWidget.QWidget: The dock's widget
"""
# First lets delete any conflicting docks
deleteDock(name)
# Then we create a workspaceControl dock using Maya's UI tools
# This gives us back the name of the dock created
ctrl = pm.workspaceControl(name, dockToMainWindow=('right', 1), label="Lighting Manager")
# We can use the OpenMayaUI API to get the actual Qt widget associated with the name
qtCtrl = omui.MQtUtil_findControl(ctrl)
# Finally we use wrapInstance to convert it to something Python can understand, in this case a QWidget
ptr = wrapInstance(long(qtCtrl), QtWidgets.QWidget)
# And we return that QWidget back to whoever wants it.
return ptr
示例6: mayaWindow
# 需要导入模块: import shiboken [as 别名]
# 或者: from shiboken import wrapInstance [as 别名]
def mayaWindow():
"""
Get Maya's main window.
:rtype: QMainWindow
"""
window = OpenMayaUI.MQtUtil.mainWindow()
window = shiboken.wrapInstance(long(window), QMainWindow)
return window
示例7: mayaToQT
# 需要导入模块: import shiboken [as 别名]
# 或者: from shiboken import wrapInstance [as 别名]
def mayaToQT(name):
"""
Maya -> QWidget
:param str name: Maya name of an ui object
:return: QWidget of parsed Maya name
:rtype: QWidget
"""
ptr = OpenMayaUI.MQtUtil.findControl(name)
if ptr is None:
ptr = OpenMayaUI.MQtUtil.findLayout(name)
if ptr is None:
ptr = OpenMayaUI.MQtUtil.findMenuItem(name)
if ptr is not None:
return shiboken.wrapInstance(long(ptr), QWidget)
示例8: mayaWindow
# 需要导入模块: import shiboken [as 别名]
# 或者: from shiboken import wrapInstance [as 别名]
def mayaWindow():
"""
Get Maya's main window.
:rtype: QMainWindow
"""
window = OpenMayaUI.MQtUtil.mainWindow()
window = shiboken.wrapInstance(long(window), QMainWindow)
return window
# ----------------------------------------------------------------------------
示例9: mayaWindow
# 需要导入模块: import shiboken [as 别名]
# 或者: from shiboken import wrapInstance [as 别名]
def mayaWindow():
"""
Get Maya's main window.
:rtype: QMainWindow
"""
window = OpenMayaUI.MQtUtil.mainWindow()
window = shiboken.wrapInstance(long(window), QMainWindow)
return window
# ----------------------------------------------------------------------------
示例10: main_window
# 需要导入模块: import shiboken [as 别名]
# 或者: from shiboken import wrapInstance [as 别名]
def main_window(self):
"""Returns the Qt main window used to parent dialogs/widgets."""
if not MAYA_UI_IMPORTED:
return None
if not hasattr(self, '_main_window'):
self._main_window = wrapInstance(
long(omui.MQtUtil.mainWindow()), QtGui.QWidget)
return self._main_window
# -------------------------------------------------------------------------
示例11: get_maya_window
# 需要导入模块: import shiboken [as 别名]
# 或者: from shiboken import wrapInstance [as 别名]
def get_maya_window():
try:
return shiboken.wrapInstance(long(OpenMayaUI.MQtUtil.mainWindow()), QWidget)
except:
return None
示例12: _qt_import
# 需要导入模块: import shiboken [as 别名]
# 或者: from shiboken import wrapInstance [as 别名]
def _qt_import(binding, shi=False, cui=False):
QtGui = None
QtCore = None
QtWidgets = None
wrapInstance = None
if binding == "PySide2":
from PySide2 import QtGui, QtCore, QtWidgets
import shiboken2 as shiboken
from shiboken2 import wrapInstance
from pyside2uic import compileUi
elif binding == "PySide":
from PySide import QtGui, QtCore
import PySide.QtGui as QtWidgets
import shiboken
from shiboken import wrapInstance
from pysideuic import compileUi
elif binding == "PyQt4":
from PyQt4 import QtGui
from PyQt4 import QtCore
import PyQt4.QtGui as QtWidgets
from sip import wrapinstance as wrapInstance
from PyQt4.uic import compileUi
print("Warning: 'shiboken' is not supported in 'PyQt4' Qt binding")
shiboken = None
else:
raise Exception("Unsupported python Qt binding '%s'" % binding)
rv = [QtGui, QtCore, QtWidgets, wrapInstance]
if shi:
rv.append(shiboken)
if cui:
rv.append(compileUi)
return rv
示例13: maya_main_window
# 需要导入模块: import shiboken [as 别名]
# 或者: from shiboken import wrapInstance [as 别名]
def maya_main_window():
"""Get Maya's main window
Returns:
QMainWindow: main window.
"""
main_window_ptr = omui.MQtUtil.mainWindow()
return QtCompat.wrapInstance(long(main_window_ptr), QtWidgets.QWidget)
示例14: initializeCallback
# 需要导入模块: import shiboken [as 别名]
# 或者: from shiboken import wrapInstance [as 别名]
def initializeCallback(self):
#get current model panel
self.currentModelPanel = cmds.getPanel(wf = 1)
if "modelPanel" not in self.currentModelPanel:
self.currentModelPanel = cmds.getPanel(vis = 1)
for i in self.currentModelPanel:
if "modelPanel" in i:
self.currentModelPanel = i
#try removing old callbacks from memory
try:
OpenMayaUI.MUiMessage.removeCallback(self.callBack)
except:
pass
#create a callback that is registered after a frame is drawn with a 3D content but before 2D content
self.callback = OpenMayaUI.MUiMessage.add3dViewPostRenderMsgCallback(self.currentModelPanel, self.update)
self.view3D.refresh(True, True)
#create QT maya window event filter
main_window_ptr = OpenMayaUI.MQtUtil.mainWindow()
self.qt_Maya_Window = wrapInstance(long(main_window_ptr), QtCore.QObject)
self.qt_Maya_Window.installEventFilter(self.userKeyboardEvents)
#create viewport event filter
active_view_ptr = self.view3D.widget()
self.qt_Active_View = wrapInstance(long(active_view_ptr), QtCore.QObject)
self.qt_Active_View.installEventFilter(self.userMouseEvents)
cmds.inViewMessage( amg='<hl>Tool:</hl> Use <hl>"Esc"</hl> to cancel the tool', pos='botLeft', fade=True )
print "Initialized..."
示例15: mayaToQT
# 需要导入模块: import shiboken [as 别名]
# 或者: from shiboken import wrapInstance [as 别名]
def mayaToQT(name):
"""
Maya -> QWidget
:param str name: Maya name of an ui object
:return: QWidget of parsed Maya name
:rtype: QWidget
"""
ptr = OpenMayaUI.MQtUtil.findControl( name )
if ptr is None:
ptr = OpenMayaUI.MQtUtil.findLayout( name )
if ptr is None:
ptr = OpenMayaUI.MQtUtil.findMenuItem( name )
if ptr is not None:
return shiboken.wrapInstance( long( ptr ), QWidget )