示例#1
0
    def undercursor(self):
        def clamp(val, mi, ma):
            return max(min(val, ma), mi)

        # Get cursor position, and screen dimensions on active screen
        cursor = QtWidgets.QCursor().pos()
        screen = QtWidgets.QDesktopWidget().screenGeometry(cursor)

        # Get window position so cursor is just over text input
        xpos = cursor.x() - (self.width() / 2)
        ypos = cursor.y() - 13

        # Clamp window location to prevent it going offscreen
        xpos = clamp(xpos, screen.left(), screen.right() - self.width())
        ypos = clamp(ypos, screen.top(),
                     screen.bottom() - (self.height() - 13))

        # Move window
        self.move(xpos, ypos)
示例#2
0
 def do_drag_update(self):
     # Transpose the motion into values as a delta off of the recorded click position
     curPos = qw.QCursor().pos()
     offsetVal = self.drag_origin.y() - curPos.y()
     self.setValue(offsetVal)
示例#3
0
 def do_drag_start(self):
     # Record position
     # Grab mouse
     self.drag_origin = qw.QCursor().pos()
     self.grabMouse()