本文整理汇总了Python中sip.wrapinstance函数的典型用法代码示例。如果您正苦于以下问题:Python wrapinstance函数的具体用法?Python wrapinstance怎么用?Python wrapinstance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wrapinstance函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BuildXlate
def BuildXlate(self,scope=True,tscope=True):
self.f2c = blocks.float_to_complex()
taps = filter.firdes.low_pass ( 1.0, rate, 2000, 750, filter.firdes.WIN_HAMMING )
self.xlate = filter.freq_xlating_fir_filter_ccf ( 12, taps, 10000, rate )
self.connect( self,self.f2c, self.xlate, self )
self.connect( (self,1), (self.f2c,1) )
if scope:
self.scope = qtgui.sink_c(1024, filter.firdes.WIN_BLACKMAN_hARRIS, fc=0, bw=rate/12, name="FFT%d" % self.i, plotfreq=True,
plotwaterfall=True, plottime=True, plotconst=True)
self.connect( self.xlate, self.scope )
# Get the reference pointer to the SpectrumDisplayForm QWidget
self.pyobj = sip.wrapinstance(self.scope.pyqwidget(), QtGui.QWidget)
self.pyobj.show()
if tscope:
self.tscope = qtgui.sink_c(1024, filter.firdes.WIN_BLACKMAN_hARRIS, fc=0, bw=rate, name="Top FFT%d" % self.i, plotfreq=True,
plotwaterfall=True, plottime=False, plotconst=False)
self.connect(self.f2c,self.tscope)
self.tpyobj = sip.wrapinstance(self.tscope.pyqwidget(), QtGui.QWidget)
self.tpyobj.show()
示例2: 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()
示例3: main
def main():
import maya.OpenMayaUI as apiUI
oldDialog = apiUI.MQtUtil.findWindow('DeadlineCheckIn')
try:
sip.wrapinstance(long(oldDialog), QWidget).close()
except:
pass
pgw = DeadlineCheckIn()
pgw.show()
示例4: init_sink
def init_sink(self):
if args.output_dir:
self.logfiles = {}
logdirpath = os.path.join(args.output_dir, 'unknown-frequency.log')
self.logfiles['unknown'] = open(logdirpath, 'w+')
self.push_text('All messages will be saved in "%s". One file for each frequency.'
% args.output_dir)
self.topblock.stop()
self.topblock.wait()
self.enable_selector_buttons(False)
#
# Source/premodulation
#
# Create the selector and connect the source to it
self.sel_c = stream_selector(3, gr.sizeof_gr_complex)
self.topblock.connect(self.topblock.source, (self.sel_c.ss, 0))
self.srcsink.source_source_radio.setEnabled(True)
self.sel_c.set_output(0)
# Add the sink
self.srcsink.grsink = qtgui.sink_c(FFTSIZE, gr.firdes.WIN_BLACKMAN_hARRIS,
self.topblock.source.get_center_freq(), self.topblock.source.get_sample_rate(),
"Source Signal", True, True, True, False)
self.srcsink.grsink.set_update_time(0.1)
self.topblock.connect(self.sel_c.ss, self.srcsink.grsink)
self.srcsink.sink = sip.wrapinstance(self.srcsink.grsink.pyqwidget(), QtGui.QWidget)
self.srcsink.horizontalLayout.addWidget(self.srcsink.sink)
# add a button group for the radio buttons
self.waveselc = QtGui.QButtonGroup(self.srcsink.verticalLayout)
self.waveselc.addButton(self.srcsink.source_source_radio, 0)
self.waveselc.addButton(self.srcsink.source_xlating_radio, 1)
self.waveselc.addButton(self.srcsink.source_interpolator_radio, 2)
self.waveselc.buttonClicked[int].connect(self.waveselc_toggled)
self.srcsink.source_source_radio.setChecked(True)
#
# Demodulation
#
# Add the sink
self.sel_f = stream_selector(4, gr.sizeof_float)
self.sel_f.set_output(0)
self.demodsink.grsink = qtgui.sink_f(FFTSIZE, gr.firdes.WIN_BLACKMAN_hARRIS,
0, self.args.symrate * SPS, "Demodulated Signal", True, True, True, False)
self.demodsink.grsink.set_update_time(0.1)
self.topblock.connect(self.sel_f.ss, self.demodsink.grsink)
self.demodsink.sink = sip.wrapinstance(self.demodsink.grsink.pyqwidget(), QtGui.QWidget)
self.demodsink.horizontalLayout.addWidget(self.demodsink.sink)
# Add the button group
self.waveself = QtGui.QButtonGroup(self.demodsink.verticalLayout)
self.waveself.addButton(self.demodsink.demodulation_quaddemod_radio, 0)
self.waveself.addButton(self.demodsink.demodulation_lowpass_radio, 1)
self.waveself.addButton(self.demodsink.demodulation_clockrecovery_radio, 2)
self.waveself.addButton(self.demodsink.demodulation_bits_radio, 3)
self.waveself.buttonClicked[int].connect(self.waveself_toggled)
self.demodsink.demodulation_quaddemod_radio.setChecked(True)
#
self.topblock.start()
示例5: BuildFFT
def BuildFFT(self,scope=True):
fft0w = filter.window.blackmanharris(2048)
fft0 = fft.fft_vcc(2048, True, fft0w, True)
fft1w = filter.window.blackmanharris(2048)
fft1 = fft.fft_vcc(2048, True, fft1w, True)
self.connect(self.rx0,blocks.stream_to_vector(gr.sizeof_gr_complex, 2048),fft0)
self.connect(self.rx1,blocks.stream_to_vector(gr.sizeof_gr_complex, 2048),fft1)
v2s = blocks.vector_to_stream(gr.sizeof_float,20)
fp2 = findphase_c(2048)
self.connect(fft0,(fp2,0))
self.connect(fft1,(fp2,1))
self.connect(fp2,v2s)
if scope:
self.ffth = qtgui.histogram_sink_f(100,360,-179,180,"FFT Phase Histogram")
#self.ffth.enable_autoscale(False)
self.ffth.enable_accumulate(True)
self.ffth.enable_grid(True)
#self.histo.enable_menu(True)
self.connect(v2s,self.ffth)
self.ffthqt = sip.wrapinstance(self.ffth.pyqwidget(), QtGui.QWidget)
self.ffthqt.show()
示例6: 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)
示例7: getMayaWindow
def getMayaWindow():
'''
return maya window by Qt object..
'''
ptr = MQtUtil.mainWindow()
if ptr is not None:
return sip.wrapinstance(long(ptr),QtCore.QObject)
示例8: __init__
def __init__(self):
gr.top_block.__init__(self)
self.qapp = QtGui.QApplication(sys.argv)
data0 = 10*[0,] + 40*[1,0] + 10*[0,]
data0 += 10*[0,] + 40*[0,1] + 10*[0,]
data1 = 20*[0,] + [0,0,0,1,1,1,0,0,0,0] + 70*[0,]
# Adjust these to change the layout of the plot.
# Can be set to fractions.
ncols = 100.25
nrows = 100
fs = 200
src0 = blocks.vector_source_f(data0, True)
src1 = blocks.vector_source_f(data1, True)
thr = blocks.throttle(gr.sizeof_float, 50000)
hed = blocks.head(gr.sizeof_float, 10000000)
self.snk1 = qtgui.time_raster_sink_f(fs, nrows, ncols, [], [],
"Float Time Raster Example", 2)
self.connect(src0, thr, (self.snk1, 0))
self.connect(src1, (self.snk1, 1))
# Get the reference pointer to the SpectrumDisplayForm QWidget
pyQt = self.snk1.pyqwidget()
# Wrap the pointer as a PyQt SIP object
# This can now be manipulated as a PyQt4.QtGui.QWidget
pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)
self.main_box = dialog_box(pyWin)
self.main_box.show()
示例9: execute
def execute():
# Get the application this has been run from
appname = get_application()
# Now continue running in either Maya or Default Mode
if appname == 'maya':
print 'MAYA UI Setup'
from maya.app.general.mayaMixin import MayaQWidgetBaseMixin
import maya.OpenMayaUI as omui
main_window_ptr = omui.MQtUtil.mainWindow()
#shiboken.wrapInstance(main_window_ptr, QtCore.QObject) # Only works for PySide
parent = sip.wrapinstance(long(main_window_ptr), QtCore.QObject)
try:
test_ui.deleteLater()
except:
pass
# Create minimal UI object
try:
test_ui = NomenclateUI(parent=parent)
except:
test_ui.deleteLater()
traceback.print_exc()
elif appname == 'python':
print 'Linux UI Setup'
app = QtGui.QApplication(sys.argv)
test_ui = NomenclateUI()
sys.exit(app.exec_())
示例10: 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)
示例11: __init__
def __init__(self):
gr.top_block.__init__(self)
Rs = 8000
f1 = 100
f2 = 200
npts = 2048
self.qapp = QtGui.QApplication(sys.argv)
src1 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f1, 0.5, 0)
src2 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f2, 0.5, 0)
src = blocks.add_cc()
channel = channels.channel_model(0.001)
thr = blocks.throttle(gr.sizeof_gr_complex, 100 * npts)
self.snk1 = qtgui.const_sink_c(npts, "Constellation Example", 1)
self.connect(src1, (src, 0))
self.connect(src2, (src, 1))
self.connect(src, channel, thr, (self.snk1, 0))
self.ctrl_win = control_box()
self.ctrl_win.attach_signal1(src1)
self.ctrl_win.attach_signal2(src2)
# Get the reference pointer to the SpectrumDisplayForm QWidget
pyQt = self.snk1.pyqwidget()
# Wrap the pointer as a PyQt SIP object
# This can now be manipulated as a PyQt4.QtGui.QWidget
pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)
self.main_box = dialog_box(pyWin, self.ctrl_win)
self.main_box.show()
示例12: GetMayaMainWindow
def GetMayaMainWindow():
'''
:returns: `QtWidget` that pertains to the Maya Main Window
'''
ptr = mui.MQtUtil.mainWindow()
if ptr:
return sip.wrapinstance(long(ptr), QtCore.QObject)
示例13: 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)
示例14: 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
示例15: 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)