当前位置: 首页>>代码示例>>Python>>正文


Python shiboken.wrapInstance方法代码示例

本文整理汇总了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)

        
# ---------------------------------------------------------------------------- 
开发者ID:robertjoosten,项目名称:maya-timeline-marker,代码行数:20,代码来源:utils.py

示例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) 
开发者ID:mgear-dev,项目名称:mgear_core,代码行数:24,代码来源:pyqt.py

示例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) 
开发者ID:sol-ansano-kim,项目名称:medic,代码行数:23,代码来源:functions.py

示例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) 
开发者ID:eoyilmaz,项目名称:anima,代码行数:23,代码来源:__init__.py

示例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 
开发者ID:dgovil,项目名称:PythonForMayaSamples,代码行数:26,代码来源:lightManager.py

示例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 
开发者ID:robertjoosten,项目名称:maya-command-search,代码行数:12,代码来源:utils.py

示例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) 
开发者ID:robertjoosten,项目名称:maya-command-search,代码行数:17,代码来源:utils.py

示例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  


# ---------------------------------------------------------------------------- 
开发者ID:robertjoosten,项目名称:maya-spline-ik,代码行数:15,代码来源:ui.py

示例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


# ---------------------------------------------------------------------------- 
开发者ID:robertjoosten,项目名称:maya-retarget-blendshape,代码行数:15,代码来源:ui.py

示例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

    # ------------------------------------------------------------------------- 
开发者ID:Clemson-DPA,项目名称:dpa-pipe,代码行数:15,代码来源:session.py

示例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 
开发者ID:ShikouYamaue,项目名称:SISideBar,代码行数:7,代码来源:qt.py

示例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 
开发者ID:mgear-dev,项目名称:mgear_core,代码行数:39,代码来源:pyqt.py

示例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) 
开发者ID:mgear-dev,项目名称:mgear_core,代码行数:12,代码来源:pyqt.py

示例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..." 
开发者ID:volodinroman,项目名称:mViewportDrawOpenGL,代码行数:36,代码来源:ViewportPainter.py

示例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 ) 
开发者ID:robertjoosten,项目名称:maya-channel-box-plus,代码行数:17,代码来源:ui.py


注:本文中的shiboken.wrapInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。