Python pyqtgraph 模块,SignalProxy() 实例源码

我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用pyqtgraph.SignalProxy()

项目:InplusTrader_Linux    作者:zhengwsh    | 项目源码 | 文件源码
def __init__(self,parent):
        """Constructor"""
        self.__view = parent

        super(Crosshair, self).__init__()
        self.__vLine = pg.InfiniteLine(angle=90, movable=False)
        self.__hLine = pg.InfiniteLine(angle=0, movable=False)
        self.__textPrice = pg.TextItem('price')
        self.__textDate = pg.TextItem('date')

        #mid ?y??????????????????
        self.__textLastPrice = pg.TextItem('lastTickPrice')    

        view = self.__view

        view.addItem(self.__textDate, ignoreBounds=True)
        view.addItem(self.__textPrice, ignoreBounds=True)        
        view.addItem(self.__vLine, ignoreBounds=True)
        view.addItem(self.__hLine, ignoreBounds=True)    
        view.addItem(self.__textLastPrice, ignoreBounds=True)     
        self.proxy = pg.SignalProxy(view.scene().sigMouseMoved, rateLimit=60, slot=self.__mouseMoved)        

    #----------------------------------------------------------------------
项目:pslab-desktop-apps    作者:fossasia    | 项目源码 | 文件源码
def enableCrossHairs(self,plot,curves=[]):
        """
        Enables crosshairs on the specified plot

        .. tabularcolumns:: |p{3cm}|p{11cm}|

        ===============  ============================================================================================
        **Arguments** 
        ===============  ============================================================================================
        plot             The plot to activate this feature on
        ===============  ============================================================================================
        """

        plot.setTitle('')
        vLine = pg.InfiniteLine(angle=90, movable=False,pen=[100,100,200,200])
        plot.addItem(vLine, ignoreBounds=True)
        hLine = pg.InfiniteLine(angle=0, movable=False,pen=[100,100,200,200])
        plot.addItem(hLine, ignoreBounds=True)
        plot.hLine = hLine; plot.vLine = vLine
        crossHairPartial = functools.partial(self.crossHairEvent,plot)
        proxy = pg.SignalProxy(plot.scene().sigMouseClicked, rateLimit=60, slot=crossHairPartial)
        plot.proxy = proxy
        plot.mousePoint=None
项目:pslab-desktop-apps    作者:fossasia    | 项目源码 | 文件源码
def plot_liss(self):
        lissx = self.Liss_x.currentText()
        lissy = self.Liss_y.currentText()
        self.liss_x = self.Liss_x.currentIndex()
        self.liss_y = self.Liss_y.currentIndex()
        if not (self.channel_states[self.liss_x] and self.channel_states[self.liss_y]):
            QtGui.QMessageBox.about(self, 'Error : Insufficient Data',  'Please enable the selected channels in the oscilloscope')
            return

        self.liss_win = pg.GraphicsWindow(title="Basic plotting examples")
        self.liss_win.setWindowTitle('pyqtgraph example: Plotting')
        self.p1 = self.liss_win.addPlot(title="Lissajous: x : %s vs y : %s"%(lissx,lissy),x=self.I.achans[self.liss_x].get_yaxis(),y=self.I.achans[self.liss_y].get_yaxis())
        self.p1.setLabel('left',lissy);self.p1.setLabel('bottom',lissx)
        self.p1.getAxis('left').setGrid(170)
        self.p1.getAxis('bottom').setGrid(170)

        self.lissvLine = pg.InfiniteLine(angle=90, movable=False,pen=[100,100,200,200])
        self.p1.addItem(self.lissvLine, ignoreBounds=True)
        self.lisshLine = pg.InfiniteLine(angle=0, movable=False,pen=[100,100,200,200])
        self.p1.addItem(self.lisshLine, ignoreBounds=True)
        self.vb = self.p1.vb
        self.lissproxy = pg.SignalProxy(self.p1.scene().sigMouseClicked, rateLimit=60, slot=self.lissMouseClicked)
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def __init__(self):
        QtCore.QObject.__init__(self)

        self.scene = None
        self.frame = None
        self.quadtree = None
        self.covariance = None
        self.log = SceneLogModel(self)

        self._ = SignalProxy(self._sigQuadtreeChanged,
                             rateLimit=5,
                             delay=0,
                             slot=lambda: self.sigQuadtreeChanged.emit())

        self._log_handler = logging.Handler()
        self._log_handler.emit = self.sigLogRecord.emit

        self.qtproxy = QSceneQuadtreeProxy(self)

        self.worker_thread = QtCore.QThread()
        self.moveToThread(self.worker_thread)
        self.worker_thread.start()
项目:pslab-desktop-apps    作者:fossasia    | 项目源码 | 文件源码
def rightClickToZoomOut(self,plot):
        """
        Enables zooming out when the user presses the right mouse button on the plot

        .. tabularcolumns:: |p{3cm}|p{11cm}|

        ===============  ============================================================================================
        **Arguments** 
        ===============  ============================================================================================
        plot             The plot to activate this feature on
        ===============  ============================================================================================
        """

        clickEvent = functools.partial(self.autoRangePlot,plot)
        return pg.SignalProxy(plot.scene().sigMouseClicked, rateLimit=60, slot=clickEvent)
项目:specviz    作者:spacetelescope    | 项目源码 | 文件源码
def _setup_connections(self):
        # Connect cursor position to UI element
        # proxy = pg.SignalProxy(self._plot_item.scene().sigMouseMoved,
        #                        rateLimit=30, slot=self.cursor_moved)
        self._plot_item.scene().sigMouseMoved.connect(self.cursor_moved)
        self.button_reset.clicked.connect(self._reset_view)
项目:qudi    作者:Ulm-IQO    | 项目源码 | 文件源码
def on_activate(self):
        """ Definition and initialisation of the GUI plus staring the measurement.
        """
        self._laser_logic = self.get_connector('laserlogic')

        #####################
        # Configuring the dock widgets
        # Use the inherited class 'CounterMainWindow' to create the GUI window
        self._mw = LaserWindow()

        # Setup dock widgets
        self._mw.setDockNestingEnabled(True)
        self._mw.actionReset_View.triggered.connect(self.restoreDefaultView)

        # set up plot
        self._mw.plotWidget = pg.PlotWidget(
            axisItems={'bottom': TimeAxisItem(orientation='bottom')})
        self._mw.pwContainer.layout().addWidget(self._mw.plotWidget)

        plot1 = self._mw.plotWidget.getPlotItem()
        plot1.setLabel('left', 'power', units='W', color=palette.c1.name())
        plot1.setLabel('bottom', 'Time', units=None)
        plot1.setLabel('right', 'Temperature', units='°C', color=palette.c3.name())

        plot2 = pg.ViewBox()
        plot1.scene().addItem(plot2)
        plot1.getAxis('right').linkToView(plot2)
        plot2.setXLink(plot1)

        self.curves = {}
        colorlist = (palette.c2, palette.c3, palette.c4, palette.c5, palette.c6)
        i = 0
        for name in self._laser_logic.data:
            if name != 'time':
                curve = pg.PlotDataItem()
                if name == 'power':
                    curve.setPen(palette.c1)
                    plot1.addItem(curve)
                else:
                    curve.setPen(colorlist[(2*i) % len(colorlist)])
                    plot2.addItem(curve)
                self.curves[name] = curve
                i += 1

        self.plot1 = plot1
        self.plot2 = plot2
        self.updateViews()
        self.plot1.vb.sigResized.connect(self.updateViews)

        self.updateButtonsEnabled()
        self._mw.laserButton.clicked.connect(self.changeLaserState)
        self._mw.shutterButton.clicked.connect(self.changeShutterState)
        self.sigLaser.connect(self._laser_logic.set_laser_state)
        self.sigShutter.connect(self._laser_logic.set_shutter_state)
        self.sigCurrent.connect(self._laser_logic.set_current)
        self.sigPower.connect(self._laser_logic.set_power)
        self.sigCtrlMode.connect(self._laser_logic.set_control_mode)
        self._mw.controlModeButtonGroup.buttonClicked.connect(self.changeControlMode)
        self.sliderProxy = pg.SignalProxy(self._mw.setValueVerticalSlider.valueChanged, 0.1, 5, self.updateFromSlider)
        self._mw.setValueDoubleSpinBox.editingFinished.connect(self.updateFromSpinBox)
        self._laser_logic.sigUpdate.connect(self.updateGui)
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def __init__(self, sandbox, *args, **kwargs):
        pg.GraphicsLayoutWidget.__init__(self, **kwargs)
        self.sandbox = sandbox

        self.plots = [
            DisplacementPlot(
                sandbox,
                title='North',
                component=lambda m: m.north),
            DisplacementPlot(
                sandbox,
                title='East',
                component=lambda m: m.east),
            DisplacementVectorPlot(
                sandbox,
                title='Down',
                component=lambda m: m.down),
            DisplacementPlot(
                sandbox,
                title='LOS',
                component=lambda m: m.displacement)]
        self.plots[-1].addHintText()

        self._mov_sig = pg.SignalProxy(
            self.scene().sigMouseMoved,
            rateLimit=60, slot=self.mouseMoved)

        for ip, plt in enumerate(self.plots):
            row = ip / 2
            col = ip % 2 + 1

            self.addItem(plt, row=row, col=col)
            plt.showGrid(x=True, y=True)
            plt.hideAxis('bottom')
            plt.hideAxis('left')
            plt.vb.border = pg.mkPen(50, 50, 50)
            if ip != 0:
                plt.setXLink(self.plots[0])
                plt.setYLink(self.plots[0])

        def getAxis(plt, orientation, label):
            axis = pg.AxisItem(
                orientation=orientation,
                linkView=plt.vb)
            axis.setLabel(label, units='m')
            return axis

        plts = self.plots
        self.addItem(getAxis(plts[0], 'left', 'Northing'), row=0, col=0)
        self.addItem(getAxis(plts[1], 'left', 'Northing'), row=1, col=0)
        self.addItem(getAxis(plts[0], 'bottom', 'Easting'), row=2, col=1)
        self.addItem(getAxis(plts[1], 'bottom', 'Easting'), row=2, col=2)

        for plt in self.plots:
            plt.vb.menu = QtGui.QMenu(self)
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def __init__(self, sandbox, *args, **kwargs):
        pg.GraphicsLayoutWidget.__init__(self, **kwargs)
        self.sandbox = sandbox

        self.plots = [
            DisplacementPlot(
                sandbox,
                title='Scene Displacement',
                component=lambda m: m.reference.scene.displacement),
            DisplacementPlot(
                sandbox,
                title='Model Residual',
                component=lambda m: m.reference.difference)]
        self.plots[-1].addHintText()

        self._mov_sig = pg.SignalProxy(
            self.scene().sigMouseMoved,
            rateLimit=60, slot=self.mouseMoved)

        for ip, plt in enumerate(self.plots):
            row = ip / 2
            col = ip % 2 + 1

            self.addItem(plt, row=row, col=col)
            plt.showGrid(x=True, y=True)
            plt.hideAxis('bottom')
            plt.hideAxis('left')
            plt.vb.border = pg.mkPen(50, 50, 50)
            if ip != 0:
                plt.setXLink(self.plots[0])
                plt.setYLink(self.plots[0])

        def getAxis(plt, orientation, label):
            axis = pg.AxisItem(
                orientation=orientation,
                linkView=plt.vb)
            axis.setLabel(label, units='m')
            return axis

        plts = self.plots
        self.addItem(getAxis(plts[0], 'left', 'Northing'), row=0, col=0)
        self.addItem(getAxis(plts[1], 'left', 'Northing'), row=1, col=0)
        self.addItem(getAxis(plts[0], 'bottom', 'Easting'), row=2, col=1)
        self.addItem(getAxis(plts[1], 'bottom', 'Easting'), row=2, col=2)
项目:kite    作者:pyrocko    | 项目源码 | 文件源码
def __init__(self, model, los_arrow=False):
        pg.PlotWidget.__init__(self)
        self.model = model
        self.draw_time = 0.
        self._data = None

        border_pen = pg.mkPen(255, 255, 255, 50)
        self.image = pg.ImageItem(
            None,
            autoDownsample=False,
            border=border_pen,
            useOpenGL=True)

        self.setAspectLocked(True)
        self.plotItem.getAxis('left').setZValue(100)
        self.plotItem.getAxis('bottom').setZValue(100)
        self.setLabels(
            bottom=('Easting', 'm'),
            left=('Northing', 'm'))

        self.hint = {
            'east': 0.,
            'north': 0.,
            'value': num.nan,
            'measure': self.component.title(),
            'vlength': '03',
            'precision': '3',
        }

        self.hint_text = pg.LabelItem(
            text='',
            justify='right', size='8pt',
            parent=self.plotItem)
        self.hint_text.anchor(
            itemPos=(1., 0.),
            parentPos=(1., 0.))
        self.hint_text.text_template =\
            '<span style="font-family: monospace; color: #fff;'\
            'background-color: #000;">'\
            'East {east:08.2f} m | North {north:08.2f} m | '\
            '{measure} {value:{length}.{precision}f}</span>'
        self.hint_text.setOpacity(.6)

        self.addItem(self.image)
        self.update()

        self.transFromFrame()
        self._move_sig = pg.SignalProxy(
            self.image.scene().sigMouseMoved,
            rateLimit=25, slot=self.mouseMoved)

        if los_arrow:
            self.addLOSArrow()

        # self.addIsocurve()
        # self.scalebar()