本文整理匯總了Python中sip.wrapinstance方法的典型用法代碼示例。如果您正苦於以下問題:Python sip.wrapinstance方法的具體用法?Python sip.wrapinstance怎麽用?Python sip.wrapinstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sip
的用法示例。
在下文中一共展示了sip.wrapinstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: qt_import
# 需要導入模塊: import sip [as 別名]
# 或者: from sip 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)
示例2: get_maya_main_window
# 需要導入模塊: import sip [as 別名]
# 或者: from sip 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)
示例3: getDock
# 需要導入模塊: import sip [as 別名]
# 或者: from sip 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
示例4: __init__
# 需要導入模塊: import sip [as 別名]
# 或者: from sip import wrapinstance [as 別名]
def __init__(self, title):
self._title = title
# IDA 7+ Widgets
if USING_IDA7API:
import sip
self._form = idaapi.create_empty_widget(self._title)
self.widget = sip.wrapinstance(long(self._form), QtWidgets.QWidget)
# legacy IDA PluginForm's
else:
self._form = idaapi.create_tform(self._title, None)
if USING_PYQT5:
self.widget = idaapi.PluginForm.FormToPyQtWidget(self._form)
else:
self.widget = idaapi.PluginForm.FormToPySideWidget(self._form)
示例5: _qt_import
# 需要導入模塊: import sip [as 別名]
# 或者: from sip 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
示例6: maya_main_window
# 需要導入模塊: import sip [as 別名]
# 或者: from sip 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)
示例7: BT_GetMayaWindow
# 需要導入模塊: import sip [as 別名]
# 或者: from sip import wrapinstance [as 別名]
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)
示例8: _pyqt5
# 需要導入模塊: import sip [as 別名]
# 或者: from sip import wrapinstance [as 別名]
def _pyqt5():
"""Initialise PyQt5"""
import PyQt5 as module
_setup(module, ["uic"])
try:
import sip
Qt.QtCompat.wrapInstance = (
lambda ptr, base=None: _wrapinstance(
sip.wrapinstance, ptr, base)
)
Qt.QtCompat.getCppPointer = lambda object: \
sip.unwrapinstance(object)
except ImportError:
pass # Optional
if hasattr(Qt, "_uic"):
Qt.QtCompat.loadUi = _loadUi
if hasattr(Qt, "_QtCore"):
Qt.__binding_version__ = Qt._QtCore.PYQT_VERSION_STR
Qt.__qt_version__ = Qt._QtCore.QT_VERSION_STR
Qt.QtCompat.translate = Qt._QtCore.QCoreApplication.translate
if hasattr(Qt, "_QtWidgets"):
Qt.QtCompat.setSectionResizeMode = \
Qt._QtWidgets.QHeaderView.setSectionResizeMode
_reassign_misplaced_members("pyqt5")
示例9: get_selected_funcs
# 需要導入模塊: import sip [as 別名]
# 或者: from sip import wrapinstance [as 別名]
def get_selected_funcs():
"""
Return the list of function names selected in the Functions window.
"""
import sip
twidget = idaapi.find_widget("Functions window")
widget = sip.wrapinstance(int(twidget), QtWidgets.QWidget)
# TODO: test this
if not widget:
idaapi.warning("Unable to find 'Functions window'")
return
#
# locate the table widget within the Functions window that actually holds
# all the visible function metadata
#
table = widget.findChild(QtWidgets.QTableView)
#
# scrape the selected function names from the Functions window table
#
selected_funcs = [str(s.data()) for s in table.selectionModel().selectedRows()]
#
# re-map the scraped names as they appear in the function table, to their true
# names as they are saved in the IDB. See the match_funcs(...) function
# comment for more details
#
return match_funcs(selected_funcs)
示例10: create_dockable_widget
# 需要導入模塊: import sip [as 別名]
# 或者: from sip import wrapinstance [as 別名]
def create_dockable_widget(self, parent, dockable_name):
import sip
# create a dockable widget, and save a reference to it for later use
twidget = idaapi.create_empty_widget(dockable_name)
self._dockable_widgets[dockable_name] = twidget
# cast the IDA 'twidget' as a Qt widget for use
widget = sip.wrapinstance(int(twidget), QtWidgets.QWidget)
widget.name = dockable_name
widget.visible = False
# return the dockable QtWidget / container
return widget
示例11: _get_ida_bg_color_from_view
# 需要導入模塊: import sip [as 別名]
# 或者: from sip import wrapinstance [as 別名]
def _get_ida_bg_color_from_view(self):
"""
Get the background color of the IDA disassembly views via widget inspection.
"""
logger.debug("Attempting to get IDA disassembly background color from view...")
names = ["Enums", "Structures"]
names += ["Hex View-%u" % i for i in range(5)]
names += ["IDA View-%c" % chr(ord('A') + i) for i in range(5)]
# find a form (eg, IDA view) to analyze colors from
for window_name in names:
twidget = idaapi.find_widget(window_name)
if twidget:
break
else:
logger.debug(" - Failed to find donor view...")
return None
# touch the target form so we know it is populated
self._touch_ida_window(twidget)
# locate the Qt Widget for a form and take 1px image slice of it
import sip
widget = sip.wrapinstance(int(twidget), QtWidgets.QWidget)
pixmap = widget.grab(QtCore.QRect(0, 10, widget.width(), 1))
# convert the raw pixmap into an image (easier to interface with)
image = QtGui.QImage(pixmap.toImage())
# return the predicted background color
return QtGui.QColor(predict_bg_color(image))
示例12: _pyqt4_as_qt_object
# 需要導入模塊: import sip [as 別名]
# 或者: from sip import wrapinstance [as 別名]
def _pyqt4_as_qt_object(widget):
from sip import wrapinstance
# Seting to api level 2 to better align with PySide behavior.
sip.setapi('QDate', 2)
sip.setapi('QDateTime', 2)
sip.setapi('QString', 2)
sip.setapi('QtextStream', 2)
sip.setapi('Qtime', 2)
sip.setapi('QUrl', 2)
sip.setapi('QVariant', 2)
from PyQt4.QtGui import QWidget
if hasattr(widget, '__qt_object__'):
return widget.__qt_object__
ptr = _find_widget_ptr(widget)
return wrapinstance(long(ptr), QWidget)
示例13: _pyqt5_as_qt_object
# 需要導入模塊: import sip [as 別名]
# 或者: from sip import wrapinstance [as 別名]
def _pyqt5_as_qt_object(widget):
from PyQt5.QtWidgets import QWidget
from sip import wrapinstance
if hasattr(widget, '__qt_object__'):
return widget.__qt_object__
ptr = _find_widget_ptr(widget)
return wrapinstance(long(ptr), QWidget)
示例14: getMainWindow
# 需要導入模塊: import sip [as 別名]
# 或者: from sip import wrapinstance [as 別名]
def getMainWindow():
ptr = mui.MQtUtil.mainWindow()
mainWin = sip.wrapinstance(long(ptr), QtCore.QObject)
return mainWin
示例15: getWidgetUnderPointer
# 需要導入模塊: import sip [as 別名]
# 或者: from sip import wrapinstance [as 別名]
def getWidgetUnderPointer():
panel = cmds.getPanel(underPointer=True)
if not panel:
return None
ptr = mui.MQtUtil.findControl(panel)
widget = sip.wrapinstance(long(ptr), QtCore.QObject)
return widget