本文整理汇总了Python中sip.unwrapinstance函数的典型用法代码示例。如果您正苦于以下问题:Python unwrapinstance函数的具体用法?Python unwrapinstance怎么用?Python unwrapinstance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unwrapinstance函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: printDialog
def printDialog(self, documentName="qtgr-untitled"):
printer = QtGui.QPrinter(QtGui.QPrinter.HighResolution)
printer.setDocName(documentName)
painter = QtGui.QPainter()
dlg = QtGui.QPrintDialog(printer)
if dlg.exec_() == QtGui.QPrintDialog.Accepted:
painter.begin(printer)
os.environ["GKSconid"] = "%x!%x" % (sip.unwrapinstance(self),
sip.unwrapinstance(painter))
# upscaling to paper size and
# alignment (horizontal and vertical centering)
xscale = printer.pageRect().width() / float(self.width());
yscale = printer.pageRect().height() / float(self.height());
scale = min(xscale, yscale);
painter.translate(printer.paperRect().x() +
printer.pageRect().width() / 2,
printer.paperRect().y() +
printer.pageRect().height() / 2)
painter.scale(scale, scale);
painter.translate(-self.width() / 2, -self.height() / 2);
self.draw(True)
gr.updatews()
painter.end()
示例2: isAlive
def isAlive(qobj):
import sip
try:
sip.unwrapinstance(qobj)
except RuntimeError:
return False
return True
示例3: objectIsAlive
def objectIsAlive(obj):
''' Test whether an object is alive; that is, whether the pointer
to the object still exists. '''
import sip
try:
sip.unwrapinstance(obj)
except RuntimeError:
return False
return True
示例4: isAlive
def isAlive(qobj):
"""
Function to check if window is alive
"""
import sip
try:
sip.unwrapinstance(qobj)
except RuntimeError:
return False
return True
示例5: paintEvent
def paintEvent(self, ev):
self.painter.begin(self)
if have_pyside:
environ['GKSconid'] = "%x!%x" % (
int(shiboken.getCppPointer(self)[0]),
int(shiboken.getCppPointer(self.painter)[0]))
else:
environ["GKSconid"] = "%x!%x" % (unwrapinstance(self),
unwrapinstance(self.painter))
updatews()
self.painter.end()
示例6: isAlive
def isAlive(qobj):
"""
return True if the object qobj exist
@param qobj: the name of the attribute
@return: C{True} or C{False}
"""
import sip
try:
sip.unwrapinstance(qobj)
except RuntimeError:
return False
return True
示例7: isAlive
def isAlive(qobj):
"""is the underlying C++ object still valid?
This function is taken from the book
"Rapid GUI Programming with Python and Qt"
by Mark Summerfield."""
if qobj is None:
return False
try:
sip.unwrapinstance(qobj)
except RuntimeError:
return False
else:
return True
示例8: test_write_to_dead
def test_write_to_dead():
pidle = wx.GetApp().ProcessIdle
f = wx.Frame(None)
print sip.unwrapinstance(f)
f.Destroy()
pidle()
for x in xrange(1):
others = [wx.Frame(None) for x in xrange(10)]
print [sip.unwrapinstance(o) for o in others]
示例9: isAlive
def isAlive(qobj):
"""
Check a window is alive
"""
return True
import sip
try:
sip.unwrapinstance(qobj)
except RuntimeError:
return False
return True
示例10: SetRenderWindow
def SetRenderWindow(self,w):
""" SetRenderWindow(w: vtkRenderWindow)
Set a new render window to QVTKWidget and initialize the
interactor as well
"""
if w == self.mRenWin:
return
if self.mRenWin:
if system.systemType!='Linux':
self.mRenWin.SetInteractor(None)
if self.mRenWin.GetMapped():
self.mRenWin.Finalize()
self.mRenWin = w
if self.mRenWin:
self.mRenWin.Register(None)
if self.mRenWin.GetMapped():
self.mRenWin.Finalize()
if system.systemType=='Linux':
display = None
try:
display = int(QtGui.QX11Info.display())
except TypeError:
# This was changed for PyQt4.2
if isinstance(QtGui.QX11Info.display(), QtGui.Display):
display = sip.unwrapinstance(QtGui.QX11Info.display())
if display is not None:
v = vtk.vtkVersion()
version = [v.GetVTKMajorVersion(),
v.GetVTKMinorVersion(),
v.GetVTKBuildVersion()]
display = hex(display)[2:]
if version < [5, 7, 0]:
vp = ('_%s_void_p\0x00' % display)
elif version < [6, 2, 0]:
vp = ('_%s_void_p' % display)
else:
vp = ('_%s_p_void' % display)
self.mRenWin.SetDisplayId(vp)
self.resizeWindow(1,1)
self.mRenWin.SetWindowInfo(str(int(self.winId())))
if self.isVisible():
self.mRenWin.Start()
if not self.mRenWin.GetInteractor():
#iren = vtk.vtkRenderWindowInteractor()
iren = QVTKRenderWindowInteractor()
# if system.systemType=='Darwin':
# iren.InstallMessageProcOff()
iren.SetRenderWindow(self.mRenWin)
iren.Initialize()
# if system.systemType=='Linux':
# system.XDestroyWindow(self.mRenWin.GetGenericDisplayId(),
# self.mRenWin.GetGenericWindowId())
self.mRenWin.SetWindowInfo(str(int(self.winId())))
self.resizeWindow(self.width(), self.height())
self.mRenWin.SetPosition(self.x(), self.y())
示例11: doDialog
def doDialog(self, parentWidgetPtr):
parentWidget = wrapinstance(parentWidgetPtr, QtGui.QWidget)
self.widget = PyDiryGui.PyDiryUi(parentWidget)
self.widget.show()
return unwrapinstance(self.widget)
示例12: SetRenderWindow
def SetRenderWindow(self, w):
""" SetRenderWindow(w: vtkRenderWindow)
Set a new render window to QVTKViewWidget and initialize the
interactor as well
"""
if w == self.mRenWin:
return
if self.mRenWin:
if self.mRenWin.GetMapped():
self.mRenWin.Finalize()
self.mRenWin = w
if self.mRenWin:
self.mRenWin.Register(None)
if system.systemType == "Linux":
try:
vp = "_%s_void_p" % (hex(int(QtGui.QX11Info.display()))[2:])
except TypeError:
# This was change for PyQt4.2
if isinstance(QtGui.QX11Info.display(), QtGui.Display):
display = sip.unwrapinstance(QtGui.QX11Info.display())
vp = "_%s_void_p" % (hex(display)[2:])
self.mRenWin.SetDisplayId(vp)
if not self.mRenWin.GetMapped():
self.mRenWin.GetInteractor().Initialize()
system.XDestroyWindow(self.mRenWin.GetGenericDisplayId(), self.mRenWin.GetGenericWindowId())
self.mRenWin.Finalize()
self.mRenWin.SetWindowInfo(str(int(self.winId())))
else:
self.mRenWin.SetWindowInfo(str(int(self.winId())))
if self.isVisible():
self.mRenWin.Start()
示例13: _pyqt5
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")
_build_compatibility_members('PyQt5')
示例14: unwrap_instance
def unwrap_instance(qt_object):
'''Return pointer address for qt class instance
'''
if globals().has_key('sip'):
return long(sip.unwrapinstance(qt_object))
elif globals().has_key('shiboken'):
return long(shiboken.getCppPointer(qt_object)[0])
示例15: create
def create(docked=True):
global dialog
if dialog is None:
dialog = InterpolateIt()
if docked is True:
ptr = mui.MQtUtil.mainWindow()
main_window = sip.wrapinstance(long(ptr), qc.QObject)
dialog.setParent(main_window)
size = dialog.size()
name = mui.MQtUtil.fullName(long(sip.unwrapinstance(dialog)))
dock = mc.dockControl(
allowedArea =['right', 'left'],
area = 'right',
floating = False,
content = name,
width = size.width(),
height = size.height(),
label = 'Interpolate It')
widget = mui.MQtUtil.findControl(dock)
dock_widget = sip.wrapinstance(long(widget), qc.QObject)
dialog.connectDockWidget(dock, dock_widget)
else:
dialog.show()