Python PyQt4.QtCore 模块,QPoint() 实例源码

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

项目:code    作者:ActiveState    | 项目源码 | 文件源码
def update_panel_position(self):
        widget = self.INPUT_WIDGET
        if not widget: return

        widget_rect         = widget.rect()
        widget_bottom       = widget.mapToGlobal(QtCore.QPoint(widget.frameGeometry().x(), widget.frameGeometry().y())).y()
        screen_height       = QtGui.qApp.desktop().availableGeometry().height()
        input_panel_height  = self.geometry().height() + 5

        if (screen_height - widget_bottom) > input_panel_height:
            # display input panel at bottom of widget
            panelPos = QtCore.QPoint(widget_rect.left(), widget_rect.bottom() + 2)
        else:
            # display input panel at top of widget
            panelPos = QtCore.QPoint(widget_rect.left(), widget_rect.top() - input_panel_height)

        panelPos = widget.mapToGlobal(panelPos)
        self.move(panelPos)
项目:quartz-browser    作者:ksharindam    | 项目源码 | 文件源码
def contextMenuEvent(self, e):
        self.rel_pos = e.pos()
        self.rowClicked = self.rowAt(self.rel_pos.y())
        if self.rowClicked == -1: return
        offset = QtCore.QPoint(self.verticalHeader().width()+3,self.horizontalHeader().height()+3)
        menu = QtGui.QMenu(self)
        if len(self.selectedIndexes())==4:
            if self.model().downloadlist[self.rowClicked].progress == '- - -':
                if self.model().downloadlist[self.rowClicked].support_resume:
                  menu.addAction(QtGui.QIcon.fromTheme('media-playback-start'), "Resume", self.pause_resume)
                else:
                  menu.addAction(QtGui.QIcon.fromTheme('view-refresh'), "Restart", self.pause_resume)
            else:
                if self.model().downloadlist[self.rowClicked].support_resume:
                    menu.addAction(QtGui.QIcon.fromTheme('media-playback-pause'), "Pause", self.pause_resume)
                else:
                    menu.addAction(QtGui.QIcon.fromTheme('process-stop'), "Stop", self.pause_resume)
            menu.addAction(QtGui.QIcon.fromTheme('edit-copy'), "Copy Address", self.copy_address)
        menu.addAction(QtGui.QIcon.fromTheme('edit-clear'), "Remove Download", self.remove_selected)
        menu.addAction(QtGui.QIcon.fromTheme('edit-delete'), "Delete File(s)", self.delete_selected)
        menu.exec_(self.mapToGlobal(self.rel_pos + offset))
项目:siren    作者:ozsolarwind    | 项目源码 | 文件源码
def editSects(self):
        config = ConfigParser.RawConfigParser()
        config.read(self.config_file)
        sections = sorted(config.sections())
        menu = QtGui.QMenu()
        stns = []
        for section in sections:
            stns.append(menu.addAction(section))
            x = self.frameGeometry().left() + 50
            y = self.frameGeometry().y() + 50
        action = menu.exec_(QtCore.QPoint(x, y))
        if action is not None:
            section = str(action.text())
            EditSect(section, self.scenarios)
            comment = section + ' Section edited. Reload may be required.'
            self.view.emit(QtCore.SIGNAL('statusmsg'), comment)
项目:siren    作者:ozsolarwind    | 项目源码 | 文件源码
def go_ToLoad(self):
        if len(self.view.scene().load_centre) == 1:
            j = 0
        else:
            menu = QtGui.QMenu()
            ctrs = []
            for ctr in self.view.scene().load_centre:
                ctrs.append(menu.addAction(ctr[0]))
           #      ctrs[-1].setIconVisibleInMenu(True)
            x = self.frameGeometry().left() + 50
            y = self.frameGeometry().y() + 50
            action = menu.exec_(QtCore.QPoint(x, y))
            if action is not None:
                for j in range(len(self.view.scene().load_centre)):
                    if action.text() == self.view.scene().load_centre[j][0]:
                        break
        if j < len(self.view.scene().load_centre):
            go_to = self.mapFromLonLat(QtCore.QPointF(self.view.scene().load_centre[j][2],
                    self.view.scene().load_centre[j][1]))
            self.view.centerOn(go_to)
            comment = '(%s,%s) Centred on %s Load Centre' % (
                      '{:0.4f}'.format(self.view.scene().load_centre[j][1]),
                      '{:0.4f}'.format(self.view.scene().load_centre[j][2]),
                      self.view.scene().load_centre[j][0])
            self.view.emit(QtCore.SIGNAL('statusmsg'), comment)
项目:siren    作者:ozsolarwind    | 项目源码 | 文件源码
def editSects(self):
        config = ConfigParser.RawConfigParser()
        config.read(self.config_file)
        sections = sorted(config.sections())
        menu = QtGui.QMenu()
        stns = []
        for section in sections:
            stns.append(menu.addAction(section))
            x = self.frameGeometry().left() + 50
            y = self.frameGeometry().y() + 50
        action = menu.exec_(QtCore.QPoint(x, y))
        if action is not None:
            section = str(action.text())
            EditSect(section, None, ini_file=self.config_file)
            comment = section + ' Section edited. Reload may be required.'
            self.view.emit(QtCore.SIGNAL('statusmsg'), comment)
项目:spyglass    作者:Crypta-Eve    | 项目源码 | 文件源码
def mousePressEvent(self, mouseEvent):
        pos = mouseEvent.pos()

        if self.pointInScroller(pos, QtCore.Qt.Vertical) or self.pointInScroller(pos, QtCore.Qt.Horizontal):
            self.clickedInScrollBar = True
        else:
            if self.ignored.count(mouseEvent):
                self.ignored.remove(mouseEvent)
                return QWebView.mousePressEvent(self, mouseEvent)

            if not self.pressed and not self.scrolling and mouseEvent.modifiers() == QtCore.Qt.NoModifier:
                if mouseEvent.buttons() == QtCore.Qt.LeftButton:
                    self.pressed = True
                    self.scrolling = False
                    self.handIsClosed = False
                    QApplication.setOverrideCursor(QtCore.Qt.OpenHandCursor)

                    self.position = mouseEvent.pos()
                    frame = self.page().mainFrame()
                    xTuple = frame.evaluateJavaScript("window.scrollX").toInt()
                    yTuple = frame.evaluateJavaScript("window.scrollY").toInt()
                    self.offset = QPoint(xTuple[0], yTuple[0])
                    return

        return QWebView.mousePressEvent(self, mouseEvent)
项目:Cite    作者:siudej    | 项目源码 | 文件源码
def __init__(self):
        """ Initialize main window. """
        QMainWindow.__init__(self)
        self.setupUi(self)
        self.resize(QSize(settings.get('citewidth'),
                          settings.get('citeheight')))
        self.move(QPoint(settings.get('citex'),
                         settings.get('citey')))
        self.tabWidget.tabBar().setCurrentIndex(0)
        self.searchTab.setFocus()
        self.setWindowTitle('Cite')
        self.show()
        self.raise_()

        self.linkSettings()

        self.searchQuery.installEventFilter(self)
        self.text = self.bibtext = self.lastquery = ""
        self.batchBibtext = self.batchText = ""
        self.neverOpened = True

        self.helpText.setSource(QUrl('doc/help.html'))
项目:picasso    作者:jungmannlab    | 项目源码 | 文件源码
def mouseReleaseEvent(self, event):
        if event.button() == QtCore.Qt.LeftButton:
            self.roi_end = QtCore.QPoint(event.pos())
            dx = abs(self.roi_end.x() - self.roi_origin.x())
            dy = abs(self.roi_end.y() - self.roi_origin.y())
            if dx < 10 or dy < 10:
                self.roi = None
                self.rubberband.hide()
            else:
                roi_points = (self.mapToScene(self.roi_origin), self.mapToScene(self.roi_end))
                self.roi = list([[int(_.y()), int(_.x())] for _ in roi_points])
            self.window.draw_frame()
        elif event.button() == QtCore.Qt.RightButton:
            self.pan = False
            self.setCursor(QtCore.Qt.ArrowCursor)
            event.accept()
        else:
            event.ignore()
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def showEvent(self, event):
        max_width = self.width()-self.viewport().width()+max([self.sizeHintForColumn(0)])
        min_width = self.main.width()
        self.setMaximumWidth(max_width if max_width > min_width else min_width)
        desktop = QtGui.QApplication.desktop().availableGeometry(self)
        geo = self.geometry()
        if not desktop.contains(geo, True):
            if geo.x() < desktop.x():
                x = desktop.x()
            elif geo.right() > desktop.right():
                x = desktop.right()-self.width()
            else:
                x = geo.x()
            if geo.y() < desktop.y():
                y = desktop.y()
            elif geo.bottom() > desktop.bottom():
                y = self.main.mapToGlobal(QtCore.QPoint(0, 0)).y()-self.height()
            else:
                y = geo.y()
            self.move(x, y)
项目:pyqt-collapsible-widget    作者:By0ute    | 项目源码 | 文件源码
def __init__(self, parent=None, title="", collapsed=False):
            QtGui.QFrame.__init__(self, parent=parent)

            self.setMinimumHeight(24)
            self.move(QtCore.QPoint(24, 0))
            self.setStyleSheet("border:1px solid rgb(41, 41, 41); ")

            self._hlayout = QtGui.QHBoxLayout(self)
            self._hlayout.setContentsMargins(0, 0, 0, 0)
            self._hlayout.setSpacing(0)

            self._arrow = None
            self._title = None

            self._hlayout.addWidget(self.initArrow(collapsed))
            self._hlayout.addWidget(self.initTitle(title))
项目:Semi-automatic-Annotation    作者:Luoyadan    | 项目源码 | 文件源码
def _draw_dots(self, points, color):
        # draw_dots using qt canvas
        r, g, b, o = color      

        if self.img_arr is None:
            self.img_arr = self.ref_pic.img_arr
        qImg = cvtrgb2qtimage(self.img_arr)
        image = QtGui.QPixmap(qImg)

        radx = 2
        rady = 2
        draw = QtGui.QPainter()
        draw.begin(image)
        draw.setBrush(QtGui.QColor(r, g, b, o))
        for p in points:
            center = QtCore.QPoint(p[1], p[0])
            draw.drawEllipse(center, radx, rady)
        draw.end()
        self.setPixmap(image)
项目:Semi-automatic-Annotation    作者:Luoyadan    | 项目源码 | 文件源码
def _draw_dots(self, points, color):
        # draw_dots using qt canvas
        r, g, b, o = color      

        if self.img_arr is None:
            self.img_arr = self.ref_pic.img_arr
        qImg = cvtrgb2qtimage(self.img_arr)
        image = QtGui.QPixmap(qImg)

        radx = 2
        rady = 2
        draw = QtGui.QPainter()
        draw.begin(image)
        draw.setBrush(QtGui.QColor(r, g, b, o))
        for p in points:
            center = QtCore.QPoint(p[1], p[0])
            draw.drawEllipse(center, radx, rady)
        draw.end()
        self.setPixmap(image)
项目:PH5    作者:PIC-IRIS    | 项目源码 | 文件源码
def on_mouse_release(self,event):
        #print "on_mouse_release"
        if not self.enableDrawing: return
        if QtGui.QApplication.keyboardModifiers() == QtCore.Qt.ShiftModifier: return
        if event._button == 1:
            # this call is for showing info on the control panel
            self.defineViewWindow(0, 0, self.width, self.height)
        if not self.select: return
        if event == None: return
        x0, y0 = event.press_event.pos
        x1, y1 = event.last_event.pos

        self.zoomWidget.setGeometry(QtCore.QRect(QPoint(x0+self.offsetX,y0+self.offsetY), 
                                                 QPoint(x1+self.offsetX,y1+self.offsetY)).normalized())
        self.zoomWidget.show()   
        if x0 > x1: x0, x1 = x1, x0
        if y0 > y1: y0, y1 = y1, y0
        #print "x0=%s, y0=%s, x1=%s, y1=%s" % (x0,y0,x1,y1)
        v = self.defineViewWindow(x0, y0, x1, y1, setData=False)
        if v!=False:
            #print "on_mouse_release: ", v 
            self.LT, self.RB = v 
            # save this new values for selection to zoom or pass to support window

        else: self.zoomWidget.hide()
项目:PH5    作者:PIC-IRIS    | 项目源码 | 文件源码
def eventFilter(self, object, event):
        if not self.submitType and not self.PH5View.helpEnable: return False
        if self.submitType and not self.helpEnable: return False

        if event.type() == QtCore.QEvent.Enter:

            if object not in self.EXPL.keys(): return False
            #print object
            P = object.pos()
            #print P
            if object.__class__.__name__ == 'QRadioButton' \
            or (not self.submitType and object.__class__.__name__ == 'QCheckBox'):
                QtGui.QToolTip.showText(self.scrollPanel.mapToGlobal(QtCore.QPoint(P.x(), P.y()+20)), self.EXPL[object])
            else:
                QtGui.QToolTip.showText(self.mapToGlobal(QtCore.QPoint(P.x(), P.y()+20)), self.EXPL[object])

            return True
        return False
项目:BTCeTrader    作者:ch3ll0v3k    | 项目源码 | 文件源码
def paintEvent(self, event):

        # -------------------------------------------------------------------
        Painter = QPainter()
        Painter.begin(self)

        # -------------------------------------------------------------------
        # Draw CROSS-MOUSE-POS
        if self.DRAW_CROSS:

            Painter.setPen( QPen( QColor(255,255,255, 255), 1, Qt.DashLine ) );
            Painter.drawPolyline( QPoint(self.MOUSE_X-600, self.MOUSE_Y), QPoint( self.MOUSE_X+600, self.MOUSE_Y) ); 
            Painter.drawPolyline( QPoint(self.MOUSE_X, self.MOUSE_Y-400), QPoint( self.MOUSE_X, self.MOUSE_Y+400) ); 

        # -------------------------------------------------------------------
        Painter.end();
        # -------------------------------------------------------------------

    # =======================================================================
项目:quartz-browser    作者:ksharindam    | 项目源码 | 文件源码
def onLinkHover(self, url):
        if url=="":
            self.statusbar.hide()
            return
        self.statusbar.setText(url)
        self.statusbar.adjustSize()
        self.statusbar.show()
        self.statusbar.move(QPoint(0, self.height()-self.statusbar.height()))
项目:linkchecker-gui    作者:linkcheck    | 项目源码 | 文件源码
def toggle_list (self):
        """Show or hide list of documents."""
        if self.listview.isHidden():
            self.listview.adjustSize()
            point = self.mapToGlobal(QtCore.QPoint(0, self.height()))
            self.listview.move(point)
            self.listview.setFocus()
            self.listview.show()
        else:
            self.listview.hide()
项目:segyviewer    作者:Statoil    | 项目源码 | 文件源码
def _subplot_clicked(self, event):
        keys = event['key']

        if self._context.indicators and event['button'] == 1 and not keys:
            x = int(event['x'])
            y = int(event['y'])
            slice_model = self._get_slice_view(event).model()
            self._context.update_index_for_direction(slice_model.x_index_direction, x)
            self._context.update_index_for_direction(slice_model.y_index_direction, y)

        elif event['button'] == 3 and (not keys or keys.state(ctrl=True)):
            subplot_index = event['subplot_index']
            context_menu = self._create_slice_view_context_menu(subplot_index)
            context_menu.exec_(self.mapToGlobal(QPoint(event['mx'], self.height() - event['my'])))
项目:siren    作者:ozsolarwind    | 项目源码 | 文件源码
def go_ToTown(self):
     #   to cater for windows I've created submenus
        menu = QtGui.QMenu()
        twns = []
        submenus = []
        submenus.append(QtGui.QMenu('A...'))
        titl = ''
        ctr = 0
        for town in sorted(self.view.scene()._towns.towns, key=lambda town: town.name):
            if titl == '':
                titl = town.name + ' to '
            twns.append(submenus[-1].addAction(town.name))
            twns[-1].setIconVisibleInMenu(True)
            ctr += 1
            if ctr > 25:
                titl += town.name
                submenus[-1].setTitle(titl)
                titl = ''
                menu.addMenu(submenus[-1])
                submenus.append(QtGui.QMenu(town.name[0] + '...'))
                ctr = 0
        titl += town.name
        submenus[-1].setTitle(titl)
        menu.addMenu(submenus[-1])
        x = self.frameGeometry().left() + 50
        y = self.frameGeometry().y() + 50
        action = menu.exec_(QtCore.QPoint(x, y))
        if action is not None:
            town = self.view.scene()._towns.Get_Town(action.text())
            go_to = self.mapFromLonLat(QtCore.QPointF(town.lon, town.lat))
            self.view.centerOn(go_to)
            comment = '(%s,%s) Centred on town %s' % ('{:0.4f}'.format(town.lon), '{:0.4f}'.format(town.lat),
                          town.name)
            self.view.emit(QtCore.SIGNAL('statusmsg'), comment)
项目:siren    作者:ozsolarwind    | 项目源码 | 文件源码
def show_Grid(self):
        self.view.clear_Trace()
        menu = QtGui.QMenu()
        lins = []
       #  for li in range(len(self.view.scene().lines.lines)): #.grid_lines):
        for li in range(self.view.scene().grid_lines):
            lins.append(menu.addAction(self.view.scene().lines.lines[li].name))
            lins[-1].setIconVisibleInMenu(True)
        if self.view.scene().load_centre is not None:
            for li in range(self.view.scene().grid_lines, len(self.view.scene().lines.lines)):
                for j in range(len(self.view.scene().load_centre)):
                    if self.view.scene().lines.lines[li].coordinates[-1] == [self.view.scene().load_centre[j][1],
                       self.view.scene().load_centre[j][2]]:
                        lins.append(menu.addAction(self.view.scene().lines.lines[li].name))
                        lins[-1].setIconVisibleInMenu(True)
        x = self.frameGeometry().left() + 50
        y = self.frameGeometry().y() + 50
        action = menu.exec_(QtCore.QPoint(x, y))
        if action is not None:
            for li in range(len(self.view.scene().lines.lines)):
                if self.view.scene().lines.lines[li].name == action.text():
                    grid_path_len = self.view.traceGrid(None, coords=self.view.scene().lines.lines[li].coordinates)
            try:
                self.view.emit(QtCore.SIGNAL('statusmsg'), 'Grid traced for %s (%s, %s Km)' % (action.text(),
                               self.view.scene().lines.lines[li].line_table, '{:0.1f}'.format(grid_path_len)))
            except:
                self.view.emit(QtCore.SIGNAL('statusmsg'), 'No Grid line for %s' % action.text())
项目:quantdigger    作者:andyzsf    | 项目源码 | 文件源码
def paintEvent(self, event):
        painter = QStylePainter(self)

        # ticks
        opt = QStyleOptionSlider()
        self.initStyleOption(opt)
        opt.subControls = QStyle.SC_SliderTickmarks
        painter.drawComplexControl(QStyle.CC_Slider, opt)

        # groove
        opt.sliderPosition = 20
        opt.sliderValue = 0
        opt.subControls = QStyle.SC_SliderGroove
        painter.drawComplexControl(QStyle.CC_Slider, opt)

        # handle rects
        opt.sliderPosition = self.lowerPos
        lr = self.style().subControlRect(QStyle.CC_Slider, opt, QStyle.SC_SliderHandle, self)
        lrv  = self.pick(lr.center())
        opt.sliderPosition = self.upperPos
        ur = self.style().subControlRect(QStyle.CC_Slider, opt, QStyle.SC_SliderHandle, self)
        urv  = self.pick(ur.center())

        # span
        minv = min(lrv, urv)
        maxv = max(lrv, urv)
        c = self.style().subControlRect(QStyle.CC_Slider, opt, QStyle.SC_SliderGroove, self).center()
        spanRect = QRect(QPoint(c.x() - 2, minv), QPoint(c.x() + 1, maxv))
        if self.orientation() == QtCore.Qt.Horizontal:
            spanRect = QRect(QPoint(minv, c.y() - 2), QPoint(maxv, c.y() + 1))
        self.drawSpan(painter, spanRect)

        # handles
        if self.lastPressed == QxtSpanSlider.LowerHandle:
            self.drawHandle(painter, QxtSpanSlider.UpperHandle)
            self.drawHandle(painter, QxtSpanSlider.LowerHandle)
        else:
            self.drawHandle(painter, QxtSpanSlider.LowerHandle)
            self.drawHandle(painter, QxtSpanSlider.UpperHandle)
项目:spyglass    作者:Crypta-Eve    | 项目源码 | 文件源码
def setInitialMapPositionForRegion(self, regionName):
        try:
            if not regionName:
                regionName = self.cache.getFromCache("region_name")
            if regionName:
                xy = self.mapPositionsDict[regionName]
                self.initialMapPosition = QPoint(xy[0], xy[1])
        except Exception:
            pass
项目:spyglass    作者:Crypta-Eve    | 项目源码 | 文件源码
def pointInScroller(self, position, orientation):
        rect = self.page().mainFrame().scrollBarGeometry(orientation)
        leftTop = self.mapToGlobal(QtCore.QPoint(rect.left(), rect.top()))
        rightBottom = self.mapToGlobal(QtCore.QPoint(rect.right(), rect.bottom()))
        globalRect = QtCore.QRect(leftTop.x(), leftTop.y(), rightBottom.x(), rightBottom.y())
        return globalRect.contains(self.mapToGlobal(position))
项目:picasso    作者:jungmannlab    | 项目源码 | 文件源码
def mousePressEvent(self, event):
        if self._mode == 'Zoom':
            if event.button() == QtCore.Qt.LeftButton:
                if not self.rubberband.isVisible():
                    self.origin = QtCore.QPoint(event.pos())
                    self.rubberband.setGeometry(QtCore.QRect(self.origin, QtCore.QSize()))
                    self.rubberband.show()
            elif event.button() == QtCore.Qt.RightButton:
                self._pan = True
                self.pan_start_x = event.x()
                self.pan_start_y = event.y()
                self.setCursor(QtCore.Qt.ClosedHandCursor)
                event.accept()
            else:
                event.ignore()
项目:picasso    作者:jungmannlab    | 项目源码 | 文件源码
def mousePressEvent(self, event):
        if event.button() == QtCore.Qt.LeftButton:
            self.roi_origin = QtCore.QPoint(event.pos())
            self.rubberband.setGeometry(QtCore.QRect(self.roi_origin, QtCore.QSize()))
            self.rubberband.show()
        elif event.button() == QtCore.Qt.RightButton:
            self.pan = True
            self.pan_start_x = event.x()
            self.pan_start_y = event.y()
            self.setCursor(QtCore.Qt.ClosedHandCursor)
            event.accept()
        else:
            event.ignore()
项目:PyQt-Image-Viewer    作者:ap193uee    | 项目源码 | 文件源码
def update(self):
        ''' This function actually draws the scaled image to the qlabel_image.
            It will be repeatedly called when zooming or panning.
            So, I tried to include only the necessary operations required just for these tasks. 
        '''
        if not self.qimage_scaled.isNull():
            # check if position is within limits to prevent unbounded panning.
            px, py = self.position
            px = px if (px <= self.qimage_scaled.width() - self.qlabel_image.width()) else (self.qimage_scaled.width() - self.qlabel_image.width())
            py = py if (py <= self.qimage_scaled.height() - self.qlabel_image.height()) else (self.qimage_scaled.height() - self.qlabel_image.height())
            px = px if (px >= 0) else 0
            py = py if (py >= 0) else 0
            self.position = (px, py)

            if self.zoomX == 1:
                self.qpixmap.fill(QtCore.Qt.white)

            # the act of painting the qpixamp
            painter = QPainter()
            painter.begin(self.qpixmap)
            painter.drawImage(QtCore.QPoint(0, 0), self.qimage_scaled,
                    QtCore.QRect(self.position[0], self.position[1], self.qlabel_image.width(), self.qlabel_image.height()) )
            painter.end()

            self.qlabel_image.setPixmap(self.qpixmap)
        else:
            pass
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def mousePressEvent(self, event):
        menu = QtGui.QMenu()
        for action in self.actions:
            menu.addAction(action)
        menu.exec_(self.mapToGlobal(QtCore.QPoint(0, self.height())))
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def resizeEvent(self, event):
        width = self.width()
        self.end = QtCore.QPoint(width-self.end_point.x()-1, self.end_point.y())
        self.conn_end = QtCore.QPoint(width-self.conn_end_point.x()-1, self.conn_end_point.y())
        self.line_end = QtCore.QPoint(width-self.line_end_point.x()-1, self.line_end_point.y())
        self.draw_horizontal_internals()
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def eventFilter(self, source, event):
        if source in self.cursors:
            if event.type() == QtCore.QEvent.MouseButtonPress and event.button() == QtCore.Qt.LeftButton:
                self.current_cursor = source
                self.current_delta = event.pos()
                return True
            elif event.type() == QtCore.QEvent.MouseMove and event.button() == QtCore.Qt.LeftButton:
                self.current_cursor = source
                self.current_delta = event.pos()
                source.setToolTip('\n'.join(['{}: {}'.format(var.capitalize().replace('_', ' '), getattr(self, var)) for var in self.cursor_labels[source]]))
                source.event(QtGui.QHelpEvent(QtCore.QEvent.ToolTip, QtCore.QPoint(20, 20), self.mapToGlobal(source.pos())+QtCore.QPoint(20, 0)))
                return True
            elif event.type() == QtCore.QEvent.MouseButtonRelease and event.button() == QtCore.Qt.LeftButton:
                self.current_cursor = self.current_delta = self.hover_point = None
                source.setToolTip('\n'.join(['{}: {}'.format(var.capitalize().replace('_', ' '), getattr(self, var)) for var in self.cursor_labels[source]]))
                source.event(QtGui.QHelpEvent(QtCore.QEvent.ToolTip, QtCore.QPoint(20, 20), self.mapToGlobal(source.pos())+QtCore.QPoint(20, 0)))
                QtGui.QApplication.changeOverrideCursor(source.cursor)
                self.repaint()
                return True
            elif event.type() == QtCore.QEvent.Enter:
                self.hover_point = source
                source.setToolTip('\n'.join(['{}: {}'.format(var.capitalize().replace('_', ' '), getattr(self, var)) for var in self.cursor_labels[source]]))
                source.event(QtGui.QHelpEvent(QtCore.QEvent.ToolTip, QtCore.QPoint(20, 20), self.mapToGlobal(source.pos())+QtCore.QPoint(20, 0)))
                QtGui.QApplication.setOverrideCursor(source.cursor)
            elif event.type() == QtCore.QEvent.Leave:
                QtGui.QApplication.restoreOverrideCursor()
#                self.repaint()
        return QtGui.QWidget.eventFilter(self, source, event)
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def mouseMoveEvent(self, event):
        if not self.current_cursor: return
        self.cursors[self.current_cursor](event.pos())
        self.current_cursor.setToolTip('\n'.join(['{}: {}'.format(var.capitalize().replace('_', ' '), getattr(self, var)) for var in self.cursor_labels[self.current_cursor]]))
        self.current_cursor.event(QtGui.QHelpEvent(QtCore.QEvent.ToolTip, QtCore.QPoint(0, 0), self.mapToGlobal(self.current_cursor.pos())+QtCore.QPoint(20, 0)))
        QtGui.QApplication.changeOverrideCursor(QtGui.QCursor(QtCore.Qt.BlankCursor))
项目:Bigglesworth    作者:MaurizioB    | 项目源码 | 文件源码
def setValue(self, value):
        self._setValue(value)
        if self.isVisible() and self.value_rect is None:
#            self.setToolTip('{}'.format(self.text_value))
            point = QtCore.QPoint(self.translate[0]+self.dial_size, self.translate[1])
            QtGui.QToolTip.showText(self.mapToGlobal(point), self.text_value, self, QtCore.QRect(0, 0, 20, 20))
#            event = QtGui.QHelpEvent(QtCore.QEvent.ToolTip, point, self.mapToGlobal(point))
#            self.event(event)
#        else:
#            self.setToolTip('{}'.format(self.text_value))
        self.valueChanged.emit(self.value)
项目:pg-history-viewer    作者:qwat    | 项目源码 | 文件源码
def onBrowseConnection(self):
        s = QSettings()
        base = "/PostgreSQL/connections"
        s.beginGroup("/PostgreSQL/connections")
        children = s.childGroups()
        connections = {}
        map = {"dbname":"database", "host":"host", "port":"port", "service":"service", "password":"password", "user":"username", "sslmode": "sslmode"}
        for g in children:
            s.beginGroup(g)
            cstring = ""
            for k, v in map.items():
                # Strings attributes.
                if s.value(v) and k != "sslmode":
                    cstring += k + "=" + s.value(v) + " "

                # Enum attributes (Ssl mode).
                elif s.value(v) and k == "sslmode":
                    mode = self.sslModeToString(s.value(v))
                    if mode != "":
                        cstring += k + "=" + mode + " "

            connections[g] = cstring
            s.endGroup()

        menu = QMenu(self)
        for k in sorted(connections.keys()):
            menu.addAction(k)

        def onMenu(action):
            self.dbConnectionText.setText(connections[action.text()])
            self.reloadBtn.click()

        menu.triggered.connect(onMenu)
        menu.exec_(self.dbConnectionBtn.mapToGlobal(QPoint(0,0)))
项目:es2-foto_personalizada    作者:leoscalco    | 项目源码 | 文件源码
def paintEvent(self, e):
        if self._frame is None:
            return
        painter = QtGui.QPainter(self)
        painter.drawImage(QtCore.QPoint(0, 0), OpenCVQImage(self._frame))
项目:pyqt-collapsible-widget    作者:By0ute    | 项目源码 | 文件源码
def initTitle(self, title=None):
            self._title = QtGui.QLabel(title)
            self._title.setMinimumHeight(24)
            self._title.move(QtCore.QPoint(24, 0))
            self._title.setStyleSheet("border:0px")

            return self._title
项目:TMV3    作者:HenricusRex    | 项目源码 | 文件源码
def getCheckBoxRect(self, option):
        check_box_style_option = QtGui.QStyleOptionButton()
        check_box_rect = QtGui.QApplication.style().subElementRect(QtGui.QStyle.SE_CheckBoxIndicator, check_box_style_option, None)
        check_box_point = QtCore.QPoint (option.rect.x() +
                            option.rect.width() / 2 -
                            check_box_rect.width() / 2,
                            option.rect.y() +
                            option.rect.height() / 2 -
                            check_box_rect.height() / 2)
        return QtCore.QRect(check_box_point, check_box_rect.size())
项目:PH5    作者:PIC-IRIS    | 项目源码 | 文件源码
def eventFilter(self, object, event):
        #print "eventFilter self.helpEnable=",self.helpEnable
        if not self.helpEnable: return False
        if event.type() == QtCore.QEvent.Enter:
            if object not in self.EXPL.keys(): return False
            #print object
            P = object.pos()
            #print P
            QtGui.QToolTip.showText(self.mapToGlobal(QtCore.QPoint(P.x(), P.y()+20)), self.EXPL[object])
            return True

        return False
项目:PH5    作者:PIC-IRIS    | 项目源码 | 文件源码
def eventFilter(self, object, event):        
        if self.PH5View.helpEnable and event.type() == QtCore.QEvent.Enter:
            if object not in self.EXPL.keys(): return False
            #print object
            P = object.pos()
            #print P
            QtGui.QToolTip.showText(self.mapToGlobal(QtCore.QPoint(P.x(), P.y()+20)), self.EXPL[object])
            return True

        if self.eventId == None: return False
        errorMsg = ''
        if object == self.offsetCtrl and event.type() == QtCore.QEvent.Leave:
            try:
                offset = float(self.offsetCtrl.text())
                if offset>20 or offset<-20:
                    errorMsg = "Offset value should not be greater than 20 or less than -20"

            except Exception, e:
                errorMsg = "Offset value must be a number."
            if errorMsg != '':
                    QtGui.QMessageBox.question(self, 'Error', errorMsg, QtGui.QMessageBox.Ok)
                    self.offsetCtrl.setText("-0")
        elif object == self.timelenCtrl:
            if event.type() in [QtCore.QEvent.Leave, QtCore.QEvent.FocusOut] :
                errorMsg = self.onChangeTimeLen()
                if errorMsg != '':
                    QtGui.QMessageBox.question(self, 'Error', errorMsg, QtGui.QMessageBox.Ok)


        return False
项目:PH5    作者:PIC-IRIS    | 项目源码 | 文件源码
def eventFilter(self, object, event):
        if not self.helpEnable: return False
        if event.type() == QtCore.QEvent.Enter:
            if object not in self.EXPL.keys(): return False
            #print object
            P = object.pos()
            #print P
            QtGui.QToolTip.showText(self.mapToGlobal(QtCore.QPoint(P.x(), P.y()+20)), self.EXPL[object])
            return True
        return False
项目:PH5    作者:PIC-IRIS    | 项目源码 | 文件源码
def eventFilter(self, object, event):        
        if event.type() == QtCore.QEvent.Enter:
            if object not in EXPL.keys(): return False
            P = object.pos()
            QtGui.QToolTip.showText(self.mapToGlobal(QtCore.QPoint(P.x(), P.y()+20)), EXPL[object])
            return True 
        return False        


    ###############################
    # def _setButtonsDisabled
    # author: Lan Dam
    # updated: 201703
    # disabled all buttons (at the beginning and when change selection criteria)
项目:SimpleImageCapture    作者:Moggi    | 项目源码 | 文件源码
def paintEvent(self, e):
        if self._frame is None:
            return
        painter = QtGui.QPainter(self)
        painter.drawImage(QtCore.QPoint(0, 0), OpenCVQImage(self._frame))
项目:BTCeTrader    作者:ch3ll0v3k    | 项目源码 | 文件源码
def mouseReleaseEvent(self, event):

        # -------------------------------------------------------------------
        if event.button() == 4: # 1 == left, 2 == right, 4 == middle

            self.FIBO_ALLOW = False;

            #self.FIBO_START = { "x":0, "y":0};
            #self.FIBO_END = { "x":0, "y":0};

            #self.FIBO_ENDET = False;
            #self.FIBO_STARTED = False;

            self.FIBO_LINE_MEMORY = [];

        self.FIBO_END["x"] = event.x();
        self.FIBO_END["y"] = event.y();
        # -------------------------------------------------------------------

        self.FIBO_STARTED = False;
        self.FIBO_ENDET = True;

        #self.LINE_MEMORY.append( [QPoint(self.START["x"],self.START["y"]), QPoint(self.END["x"],self.END["y"])] );
        self.FIBO_LINE_MEMORY.append( [self.FIBO_START["x"],self.FIBO_START["y"], self.FIBO_END["x"],self.FIBO_END["y"] ] );

        #self.START = { "x":0, "y":0};
        #self.END = { "x":0, "y":0};

        # -------------------------------------------------------------------

    # =======================================================================
项目:BTCeTrader    作者:ch3ll0v3k    | 项目源码 | 文件源码
def DRAW_CLASSIC_CANDLES(self, Painter):

        # -------------------------------------------------------------------
        # CLASSIC CANDLES

        #Painter.setPen(QPen(QColor("#FFF"), 1, Qt.NoPen));
        Painter.setPen(QPen(QColor("#FFF"), 1));

        for x_offset, y_enter, y_exit, max_val, min_val, is_growing, e_1, e_2, e_3, e_4, _upd in self.CANDLES:

            try:

                # -------------------------------------------------------
                # LINES -> drawPolyline == from_x, from_y, to_x, to_y
                if self.DRAW_PICK_LINES:
                    Painter.drawPolyline( QPoint(x_offset+self.CANDLE_W/2, min_val), QPoint(x_offset+self.CANDLE_W/2, max_val) );

                # -------------------------------------------------------                    
                # CANDLES -> drawRect == from_x, from_y, length_x, length_y
                #Painter.setPen(QPen(QColor("#444"), 0));

                if is_growing:
                    Painter.setBrush( QBrush(self.CANDLE_G_COLOR) );
                else:
                    Painter.setBrush( QBrush(self.CANDLE_R_COLOR) );

                Painter.drawRect( x_offset, y_enter, self.CANDLE_W, y_exit-y_enter );

                # -------------------------------------------------------                    

            except Exception as _NoneTypeError:

                print(_NoneTypeError)
                print("x: "+str(x_offset)+" y: "+str(y_enter))
                Painter.end()
                exit();

        # -------------------------------------------------------------------

    # =======================================================================
项目:siren    作者:ozsolarwind    | 项目源码 | 文件源码
def showPeriod(self, period):
        self.visual_group.setVisible(False)
        while len(self.visual_items) > 0:
            self.visual_group.removeFromGroup(self.visual_items[-1])
            self.visual_items.pop()
        for i in range(len(self.stations)):
            if period >= len(self.data[i]):
                continue
            if self.data[i][period] <= 0:
                continue
            st = self.scene._stations.stations[self.stn_items[i]]
            p = self.scene.mapFromLonLat(QtCore.QPointF(st.lon, st.lat))
            size = math.sqrt(self.data[i][period] * self.scene.capacity_area / math.pi)
            east = self.destinationxy(st.lon, st.lat, 90., size)
            pe = self.scene.mapFromLonLat(QtCore.QPointF(east.x(), st.lat))
            north = self.destinationxy(st.lon, st.lat, 0., size)
            pn = self.scene.mapFromLonLat(QtCore.QPointF(st.lon, north.y()))
            x_d = p.x() - pe.x()
            y_d = pn.y() - p.y()
            el = QtGui.QGraphicsEllipseItem(p.x() - x_d / 2, p.y() - y_d / 2, x_d, y_d)
            el.setBrush(QtGui.QColor(self.scene.colors[st.technology]))
            el.setOpacity(1)
            if self.scene.colors['border'] != '':
                el.setPen(QtGui.QColor(self.scene.colors['border']))
            else:
                el.setPen(QtGui.QColor(self.scene.colors[st.technology]))
            el.setZValue(1)
            self.visual_items.append(el)
            self.visual_group.addToGroup(self.visual_items[-1])
        if  self.detailCombo.currentText() == 'Diurnal':
            txt = self.periodCombo.currentText() + ' ' + self.hourCombo.currentText()
        else:
            txt = self.periodCombo.currentText() + ' ' + self.dayCombo.currentText() + ' ' + self.hourCombo.currentText()
        itm = QtGui.QGraphicsSimpleTextItem(txt)
        new_font = itm.font()
        new_font.setPointSizeF(self.scene.width() / 50)
        itm.setFont(new_font)
        itm.setBrush(QtGui.QColor(self.scene.colors['station_name']))
        fh = int(QtGui.QFontMetrics(new_font).height() * 1.1)
        p = QtCore.QPointF(self.scene.upper_left[0] + fh / 2, self.scene.upper_left[1] + fh / 2)
        frll = self.scene.mapToLonLat(p)
        p = self.scene.mapFromLonLat(QtCore.QPointF(frll.x(), frll.y()))
        p = QtCore.QPoint(p.x(), p.y())
        itm.setPos(p.x(), p.y())
        itm.setZValue(1)
        self.visual_items.append(itm)
        self.visual_group.addToGroup(self.visual_items[-1])
        self.visual_group.setVisible(True)
        QtCore.QCoreApplication.processEvents()
        QtCore.QCoreApplication.flush()
        if self.do_loop and not self.scene.exitLoop:
            if self.loopSpin.value() > 0:
                time.sleep(self.loopSpin.value())
项目:rec-attend-public    作者:renmengye    | 项目源码 | 文件源码
def drawLabelAtMouse(self, qp):
        # Nothing to do without a highlighted object
        if not self.highlightObj:
            return
        # Nothing to without a mouse position
        if not self.mousePosOrig:
            return

        # Save QPainter settings to stack
        qp.save()

        # That is the mouse positiong
        mouse = self.mousePosOrig

        # Will show zoom
        showZoom = self.zoom and not self.image.isNull() and self.w and self.h

        # The text that is written next to the mouse
        mouseText = self.highlightObj.label

        # Where to write the text
        # Depends on the zoom (additional offset to mouse to make space for zoom?)
        # The location in the image (if we are at the top we want to write below of the mouse)
        off = 36
        if showZoom:
            off += self.zoomSize/2
        if mouse.y()-off > self.toolbar.height():
            top = mouse.y()-off
            btm = mouse.y()
            vAlign = QtCore.Qt.AlignTop
        else:
            # The height of the cursor
            if not showZoom:
                off += 20
            top = mouse.y()
            btm = mouse.y()+off
            vAlign = QtCore.Qt.AlignBottom

        # Here we can draw
        rect = QtCore.QRect()
        rect.setTopLeft(QtCore.QPoint(mouse.x()-200,top))
        rect.setBottomRight(QtCore.QPoint(mouse.x()+200,btm))

        # The color
        qp.setPen(QtGui.QColor('white'))
        # The font to use
        font = QtGui.QFont("Helvetica",20,QtGui.QFont.Bold)
        qp.setFont(font)
        # Non-transparent
        qp.setOpacity(1)
        # Draw the text, horizontally centered
        qp.drawText(rect,QtCore.Qt.AlignHCenter|vAlign,mouseText)
        # Restore settings
        qp.restore()

    # Draw the zoom
项目:cityscapes-api    作者:renmengye    | 项目源码 | 文件源码
def drawLabelAtMouse(self, qp):
        # Nothing to do without a highlighted object
        if not self.highlightObj:
            return
        # Nothing to without a mouse position
        if not self.mousePosOrig:
            return

        # Save QPainter settings to stack
        qp.save()

        # That is the mouse positiong
        mouse = self.mousePosOrig

        # Will show zoom
        showZoom = self.zoom and not self.image.isNull() and self.w and self.h

        # The text that is written next to the mouse
        mouseText = self.highlightObj.label

        # Where to write the text
        # Depends on the zoom (additional offset to mouse to make space for zoom?)
        # The location in the image (if we are at the top we want to write below of the mouse)
        off = 36
        if showZoom:
            off += self.zoomSize/2
        if mouse.y()-off > self.toolbar.height():
            top = mouse.y()-off
            btm = mouse.y()
            vAlign = QtCore.Qt.AlignTop
        else:
            # The height of the cursor
            if not showZoom:
                off += 20
            top = mouse.y()
            btm = mouse.y()+off
            vAlign = QtCore.Qt.AlignBottom

        # Here we can draw
        rect = QtCore.QRect()
        rect.setTopLeft(QtCore.QPoint(mouse.x()-200,top))
        rect.setBottomRight(QtCore.QPoint(mouse.x()+200,btm))

        # The color
        qp.setPen(QtGui.QColor('white'))
        # The font to use
        font = QtGui.QFont("Helvetica",20,QtGui.QFont.Bold)
        qp.setFont(font)
        # Non-transparent
        qp.setOpacity(1)
        # Draw the text, horizontally centered
        qp.drawText(rect,QtCore.Qt.AlignHCenter|vAlign,mouseText)
        # Restore settings
        qp.restore()

    # Draw the zoom
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def readSettings(self):
        settings = QtCore.QSettings("dxf2gcode", "dxf2gcode")
        settings.beginGroup("MainWindow")
        self.resize(settings.value("size", QtCore.QSize(800, 600)).toSize())
        self.move(settings.value("pos", QtCore.QPoint(200, 200)).toPoint())
        settings.endGroup()
项目:cityscapesScripts    作者:mcordts    | 项目源码 | 文件源码
def drawLabelAtMouse(self, qp):
        # Nothing to do without a highlighted object
        if not self.highlightObj:
            return
        # Nothing to without a mouse position
        if not self.mousePosOrig:
            return

        # Save QPainter settings to stack
        qp.save()

        # That is the mouse positiong
        mouse = self.mousePosOrig

        # Will show zoom
        showZoom = self.zoom and not self.image.isNull() and self.w and self.h

        # The text that is written next to the mouse
        mouseText = self.highlightObj.label

        # Where to write the text
        # Depends on the zoom (additional offset to mouse to make space for zoom?)
        # The location in the image (if we are at the top we want to write below of the mouse)
        off = 36
        if showZoom:
            off += self.zoomSize/2
        if mouse.y()-off > self.toolbar.height():
            top = mouse.y()-off
            btm = mouse.y()
            vAlign = QtCore.Qt.AlignTop
        else:
            # The height of the cursor
            if not showZoom:
                off += 20
            top = mouse.y()
            btm = mouse.y()+off
            vAlign = QtCore.Qt.AlignBottom

        # Here we can draw
        rect = QtCore.QRect()
        rect.setTopLeft(QtCore.QPoint(mouse.x()-200,top))
        rect.setBottomRight(QtCore.QPoint(mouse.x()+200,btm))

        # The color
        qp.setPen(QtGui.QColor('white'))
        # The font to use
        font = QtGui.QFont("Helvetica",20,QtGui.QFont.Bold)
        qp.setFont(font)
        # Non-transparent
        qp.setOpacity(1)
        # Draw the text, horizontally centered
        qp.drawText(rect,QtCore.Qt.AlignHCenter|vAlign,mouseText)
        # Restore settings
        qp.restore()

    # Draw the zoom
项目:cityscapesScripts    作者:mcordts    | 项目源码 | 文件源码
def drawDrawRect(self, qp):

        qp.save()
        qp.setBrush(QtGui.QBrush(QtCore.Qt.NoBrush))
        qp.setFont(QtGui.QFont('QFont::AnyStyle', 14))
        thickPen = QtGui.QPen()
        qp.setPen(thickPen)

        for c in self.corrections:
            rect = copy.deepcopy(c.bbox)

            width = rect.width()
            height = rect.height()
            rect.setX(c.bbox.x() * self.scale + self.xoff)
            rect.setY(c.bbox.y() * self.scale + self.yoff)

            rect.setWidth(width * self.scale)
            rect.setHeight(height * self.scale)

            if c.selected:
                thickPen.setColor(QtGui.QColor(0,0,0))
                if c.type == CorrectionBox.types.QUESTION:
                    descr = "QUESTION"
                elif c.type == CorrectionBox.types.RESOLVED:
                    descr = "FIXED"
                else:
                    descr = "ERROR"
                qp.setPen(thickPen)
                qp.drawText(QtCore.QPoint( self.xoff, self.yoff + self.h + 20 ),
                                           "(%s: %s)" % (descr, c.annotation))
                pen_width = 6
            else:
                pen_width = 3

            colour = c.get_colour()
            thickPen.setColor(colour)
            thickPen.setWidth(pen_width)
            qp.setPen(thickPen)
            qp.drawRect(rect)

        if self.in_progress_bbox is not None:
            rect = copy.deepcopy(self.in_progress_bbox)
            width = rect.width()
            height = rect.height()
            rect.setX(self.in_progress_bbox.x() * self.scale + self.xoff)
            rect.setY(self.in_progress_bbox.y() * self.scale + self.yoff)

            rect.setWidth(width * self.scale)
            rect.setHeight(height * self.scale)

            thickPen.setColor(QtGui.QColor(255,0,0))
            thickPen.setWidth(3)
            qp.setPen(thickPen)
            qp.drawRect(rect)


        qp.restore()

    # Draw the polygon that is drawn and edited by the user
    # Usually the polygon must be rescaled properly. However when drawing
    # The polygon within the zoom, this is not needed. Therefore the option transform.
项目:cityscapesScripts    作者:mcordts    | 项目源码 | 文件源码
def drawLabelAtMouse(self, qp):
        # Nothing to do without a highlighted object
        if not self.highlightObjs:
            return
        # Also we do not want to draw the label, if we have a drawn polygon
        if not self.drawPoly.isEmpty():
            return
        # Nothing to without a mouse position
        if not self.mousePos:
            return

        # Save QPainter settings to stack
        qp.save()

        # That is the mouse positiong
        mouse = self.mousePos

        # Will show zoom
        showZoom = self.config.zoom and not self.image.isNull() and self.w and self.h

        # The text that is written next to the mouse
        mouseText = self.highlightObjs[-1].label

        # Where to write the text
        # Depends on the zoom (additional offset to mouse to make space for zoom?)
        # The location in the image (if we are at the top we want to write below of the mouse)
        off = 36
        if showZoom:
            off += self.config.zoomSize/2
        if mouse.y()-off > self.toolbar.height():
            top = mouse.y()-off
            btm = mouse.y()
            vAlign = QtCore.Qt.AlignTop
        else:
            # The height of the cursor
            if not showZoom:
                off += 20
            top = mouse.y()
            btm = mouse.y()+off
            vAlign = QtCore.Qt.AlignBottom

        # Here we can draw
        rect = QtCore.QRect()
        rect.setTopLeft(QtCore.QPoint(mouse.x()-100,top))
        rect.setBottomRight(QtCore.QPoint(mouse.x()+100,btm))

        # The color
        qp.setPen(QtGui.QColor('white'))
        # The font to use
        font = QtGui.QFont("Helvetica",20,QtGui.QFont.Bold)
        qp.setFont(font)
        # Non-transparent
        qp.setOpacity(1)
        # Draw the text, horizontally centered
        qp.drawText(rect,QtCore.Qt.AlignHCenter|vAlign,mouseText)
        # Restore settings
        qp.restore()

    # Draw the zoom
项目:picasso    作者:jungmannlab    | 项目源码 | 文件源码
def mouseReleaseEvent(self, event):
        if self._mode == 'Zoom':
            if event.button() == QtCore.Qt.LeftButton and self.rubberband.isVisible():
                end = QtCore.QPoint(event.pos())
                if end.x() > self.origin.x() and end.y() > self.origin.y():
                    x_min_rel = self.origin.x() / self.width()
                    x_max_rel = end.x() / self.width()
                    y_min_rel = self.origin.y() / self.height()
                    y_max_rel = end.y() / self.height()
                    viewport_height, viewport_width = self.viewport_size()
                    x_min = self.viewport[0][1] + x_min_rel * viewport_width
                    x_max = self.viewport[0][1] + x_max_rel * viewport_width
                    y_min = self.viewport[0][0] + y_min_rel * viewport_height
                    y_max = self.viewport[0][0] + y_max_rel * viewport_height
                    viewport = [(y_min, x_min), (y_max, x_max)]
                    self.update_scene(viewport)
                self.rubberband.hide()
            elif event.button() == QtCore.Qt.RightButton:
                self._pan = False
                self.setCursor(QtCore.Qt.ArrowCursor)
                event.accept()
            else:
                event.ignore()
        elif self._mode == 'Pick':
            if event.button() == QtCore.Qt.LeftButton:
                x, y = self.map_to_movie(event.pos())
                self.add_pick((x, y))
                event.accept()
            elif event.button() == QtCore.Qt.RightButton:
                x, y = self.map_to_movie(event.pos())
                self.remove_picks((x, y))
                event.accept()
            else:
                event.ignore()
        elif self._mode == 'Measure':
            if event.button() == QtCore.Qt.LeftButton:
                x, y = self.map_to_movie(event.pos())
                self.add_point((x, y))
                event.accept()
            elif event.button() == QtCore.Qt.RightButton:
                x, y = self.map_to_movie(event.pos())
                self.remove_points((x, y))
                event.accept()
            else:
                event.ignore()