コード例 #1
0
	def eventFilter ( self, o, e ):
		if o == self.sysMenuButton:
			if e.type () == QEvent.MouseButtonPress:
				if e.button () == QtCore.Qt.LeftButton and qApp.widgetAt ( QCursor.pos () ) == self.sysMenuButton:
					self.showSystemMenu ( self.mapToGlobal ( self.rect ().bottomLeft () ) )
					return True
			if e.type () == QEvent.MouseButtonDblClick:
				if e.button () == QtCore.Qt.LeftButton and qApp.widgetAt ( QCursor.pos () ) == self.sysMenuButton:
					self.parentWidget ().close ()
					return True

		return super ().eventFilter ( o, e )
コード例 #2
0
	def mousePressEvent ( self, e ):

		self.onMousePressEvent.emit ( e )

		if e.button () == QtCore.Qt.LeftButton and qApp.widgetAt ( QCursor.pos () ) != self.sysMenuButton:
			self.onBeginDrag ()
			self.mouseStartPos = e.globalPos ()
			# qWarning ( "QCustomTitleBar::onBeginDrag" )

		super ().mousePressEvent ( e )
コード例 #3
0
ファイル: DragDrop.py プロジェクト: lihaochen910/Candy
    def update(self):
        subject = qApp.widgetAt(QCursor.pos())
        scope = self.getScope(subject) if subject else self.defaultScope
        if scope.displayMode == EDisplayMode.Clear:
            QTrackingTooltip.hideTooltip(self.trackingTooltip.data())
        else:
            if scope.displayMode == EDisplayMode.Text:
                self.trackingTooltip.setText(scope.text)
            elif scope.displayMode == EDisplayMode.Pixmap:
                self.trackingTooltip.setPixmap(scope.pixmap)

            QTrackingTooltip.showTrackingTooltip(self.trackingTooltip)
コード例 #4
0
    def hook_updateMainWindowOnMouseMove_End(self):
        """
        This will run whenever the mouse moves in x or y across one of the axes in the main plot
        TODO: it would be nice to also run this on mouse wheel
        """
        x = self.lasagna.mouseX
        y = self.lasagna.mouseY

        # Get the widget that the mouse is currently in
        pos = QtGui.QCursor.pos()
        print(pos)
        print(type(qApp.widgetAt(pos)))
        if str(type(qApp.widgetAt(pos))) == "<class 'NoneType'>":
            print("\n\nBAILING OUT\n\n")
            return

        plot_widget = qApp.widgetAt(
            pos).parent()  # The mouse is in this widget

        # Get the base image from this widget
        selected_stack_name = self.lasagna.selectedStackName()
        image_item = lasagna_qt_helper_functions.find_pyqt_graph_object_name_in_plot_widget(
            plot_widget, itemName=selected_stack_name, regex=True)
        if not image_item:
            return

        # Extract data from base image
        if image_item is not None:
            if image_item.image.shape[1] <= y or y < 0:
                return
            x_data = image_item.image[:, y]

            self.graphicsView.clear()
            self.graphicsView.plot(x_data)

        # Link the x axis of the cross-section view with the x axis of the image view
        # Do not use self.graphicsView.setXLink() as it is bidirectional
        x_range = plot_widget.viewRange()[0]
        self.graphicsView.setXRange(min=x_range[0], max=x_range[1])
コード例 #5
0
ファイル: info_box_plugin.py プロジェクト: oliche/lasagna
    def hook_updateMainWindowOnMouseMove_End(self):
        z, x, y = self.lasagna.mousePositionInStack

        pos = QtGui.QCursor.pos()
        current_widget = qApp.widgetAt(pos)
        try:
            plot_widget = current_widget.parent()
            current_axis_name = plot_widget.objectName()
        except AttributeError:
            print("Mouse seems lost somewhere in a parentless widget")
            current_axis_name = "the void"

        msg = "Mouse is in %s\nZ: %d, X: %d, Y: %d" % (current_axis_name, z, x,
                                                       y)
        self.label.setText(msg)