本文整理汇总了Python中shiboken.wrapInstance函数的典型用法代码示例。如果您正苦于以下问题:Python wrapInstance函数的具体用法?Python wrapInstance怎么用?Python wrapInstance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wrapInstance函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: wrapinstance
def wrapinstance(ptr, base=None):
"""Convert a pointer to a Qt class instance.
:param int ptr: Pointer to QObject in memory.
:param class base: Base class to wrap with.
:returns: QWidget or subclass instance
"""
if ptr is None:
return None
ptr = long(ptr)
if sip is not None:
return sip.wrapinstance(ptr, base or QtCore.QObject)
if shiboken is not None:
if base is None:
# Do a generic wrap so that we can detect what type the object
# actually is.
q_obj = shiboken.wrapInstance(ptr, QtCore.QObject)
meta_obj = q_obj.metaObject()
class_name = meta_obj.className()
super_name = meta_obj.superClass().className()
base = (getattr(QtGui, class_name, None) or
getattr(QtGui, super_name, None) or
QtGui.QWidget)
return shiboken.wrapInstance(ptr, base)
开发者ID:westernx,项目名称:uitools,代码行数:31,代码来源:sip.py
示例2: wrapinstance
def wrapinstance(ptr, base = None):
"""Utility to convert a pointer to a Qt class instance (PySide/PyQt compatible)
@param ptr: Pointer to QObject in memory
@type ptr: long or Swig instance
@param base: (Optional) Base class to wrap with (Defaults to QObject,
which should handle anything)
@type base: QtGui.QWidget
@return: QWidget or subclass instance
@rtype: QtGui.QWidget
"""
if ptr is None:
return None
ptr = long(ptr)
if base is None:
qObj = shiboken.wrapInstance(long(ptr), QtCore.QObject)
metaObj = qObj.metaObject()
cls = metaObj.className()
superCls = metaObj.superClass().className()
if hasattr(QtGui, cls):
base = getattr(QtGui, cls)
elif hasattr(QtGui, superCls):
base = getattr(QtGui, superCls)
else:
base = QtGui.QWidget
return shiboken.wrapInstance(long(ptr), base)
开发者ID:jonntd,项目名称:Public,代码行数:26,代码来源:pysideconvenience.py
示例3: wrapinstance
def wrapinstance( ptr, base = None ):
"""
Nathan Horne
"""
if ptr is None:
return None
ptr = long( ptr ) #Ensure type
if globals().has_key( 'shiboken' ):
if base is None:
qObj = shiboken.wrapInstance( long( ptr ), QtCore.QObject )
metaObj = qObj.metaObject()
cls = metaObj.className()
superCls = metaObj.superClass().className()
if hasattr( QtGui, cls ):
base = getattr( QtGui, cls )
elif hasattr( QtGui, superCls ):
base = getattr( QtGui, superCls )
else:
base = QtGui.QWidget
return shiboken.wrapInstance( long( ptr ), base )
elif globals().has_key( 'sip' ):
base = QtCore.QObject
return sip.wrapinstance( long( ptr ), base )
else:
return None
开发者ID:Mortaciunea,项目名称:bdScripts,代码行数:32,代码来源:pyside_util.py
示例4: initializeCallback
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:jonntd,项目名称:ViewportPainter,代码行数:34,代码来源:ViewportPainter.py
示例5: create
def create(docked=True):
global tractor_submit_dialog
logging.info("create dialog tractor_submit_dialog")
if tractor_submit_dialog is None:
tractor_submit_dialog = TractorSubmit()
if docked is True:
ptr = mui.MQtUtil.mainWindow()
main_window = shiboken.wrapInstance(long(ptr), qg.QWidget)
tractor_submit_dialog.setParent(main_window)
size = tractor_submit_dialog.size()
name = mui.MQtUtil.fullName(long(shiboken.getCppPointer(tractor_submit_dialog)[0]))
dock = mc.dockControl(
allowedArea=["right", "left"],
area="right",
floating=False,
content=name,
width=size.width(),
height=size.height(),
label="UTS_FARM_SUBMIT",
)
widget = mui.MQtUtil.findControl(dock)
dock_widget = shiboken.wrapInstance(long(widget), qg.QWidget)
tractor_submit_dialog.connectDockWidget(dock, dock_widget)
else:
tractor_submit_dialog.show()
开发者ID:utsdab,项目名称:usr,代码行数:29,代码来源:tractor_submit_maya_integrated_UI.py
示例6: convert
def convert(mguiName):
"""
From the name of a Maya UI element of any type to pointer,
and wrap the pointer into a python QObject
:param mguiName: Maya UI Name
:type mguiName: string
:return: QWidget or subclass instance
:rtype: QtGui.QWidget
Thanks to Nathan Horne
"""
# Get pointer
ptr = MQtUtil.findControl(mguiName)
if ptr is None:
ptr = MQtUtil.findLayout(mguiName)
if ptr is None:
ptr = MQtUtil.findMenuItem(mguiName)
if ptr is None:
return None
# Find corresponding class
qObj = wrapInstance(long(ptr), QtCore.QObject)
metaObj = qObj.metaObject()
cls = metaObj.className()
superCls = metaObj.superClass().className()
if hasattr(QtGui, cls):
base = getattr(QtGui, cls)
elif hasattr(QtGui, superCls):
base = getattr(QtGui, superCls)
else:
base = QtGui.QWidget
return wrapInstance(long(ptr), base)
开发者ID:davidpower,项目名称:MS_AniRemap,代码行数:32,代码来源:mGetQt.py
示例7: wrapinstance
def wrapinstance(ptr, base=None):
"""
Utility to convert a pointer to a Qt class instance
:param ptr: Pointer to QObject in memory
:type ptr: long or Swig instance
:param base: (Optional) Base class to wrap with (Defaults to QObject, which should handle anything)
:type base: QtGui.QWidget
:return: QWidget or subclass instance
:rtype: QtGui.QWidget
"""
if ptr is None:
return None
ptr = long(ptr) #Ensure type
if qt_lib == 'pyqt':
base = QtCore.QObject
return sip.wrapinstance(long(ptr), base)
elif qt_lib == 'pyside':
#Pyside makes this a pain for us, since unlike Pyqt it does not return the "best" matching class automatically
if base is None:
qObj = shiboken.wrapInstance(long(ptr), QtCore.QObject)
metaObj = qObj.metaObject()
cls = metaObj.className()
superCls = metaObj.superClass().className()
if hasattr(QtGui, cls):
base = getattr(QtGui, cls)
elif hasattr(QtGui, superCls):
base = getattr(QtGui, superCls)
else:
base = QtGui.QWidget
return shiboken.wrapInstance(long(ptr), base)
开发者ID:Temujin2887,项目名称:mlib,代码行数:31,代码来源:qt.py
示例8: wrap_instance
def wrap_instance(ptr, base=None):
'''
Utility to convert a pointer to a Qt class instance (PySide/PyQt compatible)
:param ptr: Pointer to QObject in memory
:type ptr: long or Swig instance
:param base: (Optional) Base class to wrap with (Defaults to QObject,
which should handle anything)
:type base: QtGui.QWidget
:return: QWidget or subclass instance
:rtype: QtGui.QWidget
'''
if ptr is None:
return None
ptr = long(ptr) #Ensure type
if globals().has_key('shiboken'):
if base is None:
qObj = shiboken.wrapInstance(long(ptr), QtCore.QObject)
metaObj = qObj.metaObject()
cls = metaObj.className()
superCls = metaObj.superClass().className()
if hasattr(QtGui, cls):
base = getattr(QtGui, cls)
elif hasattr(QtGui, superCls):
base = getattr(QtGui, superCls)
else:
base = QtGui.QWidget
return shiboken.wrapInstance(long(ptr), base)
elif globals().has_key('sip'):
base = QtCore.QObject
return sip.wrapinstance(long(ptr), base)
else:
return None
开发者ID:vorcil,项目名称:pyVFX-boilerplate,代码行数:33,代码来源:boilerplate.py
示例9: pysideWrapInstance
def pysideWrapInstance(ptr, base=None):
'''Utility to convert a point to a Qt Class and produce the same result
as sip.wrapinstance using shiboken.wrapInstance.
Note: This is modeled after nathanhorne.com/?p=486. The base arg isn't
currently used, and defaults to QObject. The way that base arg was used
seems like it would give a different result than the sip version. It would
skip the checking for attribute and just use base as base, however the sip
version will still return QMainWindow even if QObject is passed in.
'''
if ptr is None:
return
import shiboken
import PySide.QtCore as qtcore
import PySide.QtGui as qtgui
qObj = shiboken.wrapInstance(long(ptr), qtcore.QObject)
metaObj = qObj.metaObject()
cls = metaObj.className()
superCls = metaObj.superClass().className()
if hasattr(qtgui, cls):
base = getattr(qtgui, cls)
elif hasattr(qtgui, superCls):
base = getattr(qtgui, superCls)
else:
base = qtgui.QWidget
return shiboken.wrapInstance(long(ptr), base)
开发者ID:demon7x,项目名称:pymel,代码行数:28,代码来源:uitypes.py
示例10: create
def create(docked=True):
global dialog
if dialog is None:
dialog = LightIt()
# docking window if statment
if docked is True:
ptr = mui.MQtUtil.mainWindow()
main_window = shiboken.wrapInstance(long(ptr), qg.QWidget)
dialog.setParent( main_window )
size = dialog.size()
#return proper full name
name = mui.MQtUtil.fullName(long(shiboken.getCppPointer(dialog)[0]))
dock = mc.dockControl(
allowedArea =['right', 'left'],
area = 'left',
floating = True,
content = name,
width = size.width(),
height = size.height(),
label = 'Lighting Tools v1.04')
# Convert to Dock widget
widget = mui.MQtUtil.findControl(dock)
dock_widget = shiboken.wrapInstance(long(widget), qc.QObject)
dialog.connectDockWidget( dock, dock_widget )
else:
dialog.show()
开发者ID:blam4521,项目名称:Tool_02_Lighting,代码行数:31,代码来源:interpolate_it_01.py
示例11: wrapinstance
def wrapinstance(ptr):
"""Converts a pointer (int or long) into the concrete PyQt / PySide object it represents """
ptr = long(ptr)
qobj = shiboken.wrapInstance(ptr, QtCore.QObject)
metaobj = qobj.metaObject()
realcls = None
while(realcls is None):
realcls = _getcls(metaobj.className())
metaobj = metaobj.superClass()
return shiboken.wrapInstance(ptr,realcls)
开发者ID:cfvalente,项目名称:rad_osx,代码行数:10,代码来源:qtshim.py
示例12: setupMannequinUI
def setupMannequinUI():
"""Sets up the side panel UI for the Mannequin plugin."""
currentContext = cmds.currentCtx()
influenceObjectsStr = cmds.mannequinContext(currentContext,
q=True,
io=True)
ioTokens = influenceObjectsStr.split(" ")
ioDagPaths = ioTokens[::2]
ioAvailableStyles = ioTokens[1::2]
mannequinDockPtr = MQtUtil.findLayout("mannequinPaletteDock")
mannequinDock = wrapInstance(long(mannequinDockPtr), QWidget)
mannequinDock.setMinimumWidth(300)
mannequinLayoutPtr = MQtUtil.findLayout("mannequinPaletteLayout")
mannequinLayout = wrapInstance(long(mannequinLayoutPtr), QWidget)
mannequinSearchPtr = MQtUtil.findControl("mannequinSearchField")
mannequinSearch = wrapInstance(long(mannequinSearchPtr), QLineEdit)
uiFile = QFile(os.path.join(os.path.dirname(__file__), "mannequin.ui"))
uiFile.open(QFile.ReadOnly)
gui = mannequinToolPanel.loader.load(uiFile, parentWidget=mannequinLayout)
uiFile.close()
selList = om.MSelectionList()
for obj in ioDagPaths:
selList.add(obj)
joints = []
for i in range(selList.length()):
dagPath = selList.getDagPath(i)
dependNode = selList.getDependNode(i)
styles = ioAvailableStyles[i]
joints.append(JointInfo(dagPath, dependNode, styles))
# Alphabetize joints by full DAG path; should sort slightly better.
joints = sorted(joints, key=lambda j: j.dagPath.fullPathName())
prefixTrim = commonPrefix(joints)
mannequinToolPanel.reset(mannequinLayout,
gui,
mannequinSearch,
prefixTrim)
jointDisplays = organizeJoints(joints)
for jointDisplay in jointDisplays:
mannequinToolPanel.layoutJointGroup(jointDisplay)
mannequinToolPanel.finishLayout()
开发者ID:jonntd,项目名称:mannequin,代码行数:51,代码来源:mannequin.py
示例13: wrap_instance
def wrap_instance(pointer, base_class=None):
ptr = long(pointer)
qObj = shiboken.wrapInstance(long(ptr), QtCore.QObject)
metaObj = qObj.metaObject()
cls = metaObj.className()
superCls = metaObj.superClass().className()
if hasattr(QtGui, cls):
base = getattr(QtGui, cls)
if hasattr(QtGui, superCls):
base = getattr(QtGui, superCls)
base = QtGui.QWidget if not base_class else base_class
return shiboken.wrapInstance(long(ptr), base)
开发者ID:griffinanimator,项目名称:ampt,代码行数:14,代码来源:user_interface.py
示例14: BT_GetMayaWindow
def BT_GetMayaWindow():
ptr = apiUI.MQtUtil.mainWindow()
if ptr is not None:
if BT_MayaVersionNumber < 2014:
return wrapinstance(long(ptr), QtCore.QObject)
else:
return wrapInstance(long(ptr), QtGui.QWidget)
开发者ID:SplineO,项目名称:BlendTransforms,代码行数:7,代码来源:BlendTransforms.py
示例15: centre
def centre(self):
# panelPtr = omui.MQtUtil.findControl('toolBar2')
panelPtr = omui.MQtUtil.findControl("modelPanel1")
if panelPtr == None:
"""
Center the main window on the screen. This implemention will handle the window
being resized or the screen resolution changing.
"""
# Get the current screens' dimensions...
screen = QtGui.QDesktopWidget().screenGeometry()
# ... and get this windows' dimensions
mysize = self.geometry()
# The horizontal position is calulated as screenwidth - windowwidth /2
hpos = (screen.width() - mysize.width()) / 2
# And vertical position the same, but with the height dimensions
vpos = (screen.height() - mysize.height()) / 2
# And the move call repositions the window
self.move(hpos + 300, vpos - 100)
else:
panel = wrapInstance(long(panelPtr), QtGui.QWidget)
position = panel.mapToGlobal(panel.pos())
# self.move(position.x(), position.y() + (panel.geometry().height() / 2 - self.geometry().height() / 2) + 5)
self.move(position.x(), position.y())
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
开发者ID:wolfpatrick,项目名称:FluidExplorerPlugin,代码行数:26,代码来源:FluidMain.py
示例16: wrapInstance
def wrapInstance(ptr):
if "PyQt4" in QtGui.__name__:
import sip
return sip.wrapinstance(long(ptr), QtCore.QObject)
elif "PySide" in QtGui.__name__:
import shiboken
return shiboken.wrapInstance(long(ptr), QtGui.QWidget)
开发者ID:wangqinghuaTudou,项目名称:test,代码行数:7,代码来源:pyqt4_note.py
示例17: shibokenGetMayaMainWindow
def shibokenGetMayaMainWindow():
mayaMainWindowPtr = apiUI.MQtUtil.mainWindow()
if mayaMainWindowPtr:
mayaMainWindow = shiboken.wrapInstance(long(mayaMainWindowPtr), QtGui.QWidget)
return mayaMainWindow
else:
return None
开发者ID:yes7rose,项目名称:maya_utils,代码行数:7,代码来源:maya_utils.py
示例18: wrap_instance
def wrap_instance(ptr, base):
'''Return QtGui object instance based on pointer address
'''
if globals().has_key('sip'):
return sip.wrapinstance(long(ptr), QtCore.QObject)
elif globals().has_key('shiboken'):
return shiboken.wrapInstance(long(ptr), base)
开发者ID:dieulinh,项目名称:anim_picker,代码行数:7,代码来源:qt_handlers.py
示例19: getMayaWindow
def getMayaWindow():
"""
Return the pointer to maya window
"""
OpenMayaUI.MQtUtil.mainWindow()
ptr = OpenMayaUI.MQtUtil.mainWindow()
return shiboken.wrapInstance(long(ptr), QtGui.QWidget)
开发者ID:renaudll,项目名称:dpAutoRigSystem,代码行数:7,代码来源:dpSpaceSwitcher.py
示例20: __init__
def __init__(self, parent = None):
# Delete any previous instances that is detected. Do this before parenting self to main window!
self.deleteInstances()
super(self.__class__, self).__init__(parent = parent)
mayaMainWindowPtr = OpenMayaUI.MQtUtil.mainWindow()
self.mayaMainWindow = wrapInstance(long(mayaMainWindowPtr), QtGui.QMainWindow)
self.setObjectName(self.__class__.toolName) # Make this unique enough if using it to clear previous instance!
# Setup window's properties
self.setWindowFlags(QtCore.Qt.Window)
self.setWindowTitle('Hand Rigger Script')
self.setFixedSize(300, 100)
# Create a button and stuff it in a layout
label = QtGui.QLabel("Select two hands (right and left) and run script: ", parent=self)
label.setAlignment(QtCore.Qt.AlignRight)
label.setGeometry(0, 15, 280, 20)
self.myButton = QtGui.QPushButton('Run')
self.mainLayout = QtGui.QVBoxLayout()
self.mainLayout.addWidget(self.myButton)
self.setLayout(self.mainLayout)
self.myButton.clicked.connect(self.buttonPush)
开发者ID:RiggingDojo,项目名称:AnomaliaRigging,代码行数:26,代码来源:hand_rigger.py
注:本文中的shiboken.wrapInstance函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论