python类LeftButton()的实例源码

QVTKRenderWindowInteractor.py 文件源码 项目:mhri 作者: mhri 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def mousePressEvent(self, ev):
        ctrl, shift = self._GetCtrlShift(ev)
        repeat = 0
        if ev.type() == QEvent.MouseButtonDblClick:
            repeat = 1
        self._Iren.SetEventInformationFlipY(ev.x(), ev.y(),
                                            ctrl, shift, chr(0), repeat, None)

        self._ActiveButton = ev.button()

        if self._ActiveButton == Qt.LeftButton:
            self._Iren.LeftButtonPressEvent()
        elif self._ActiveButton == Qt.RightButton:
            self._Iren.RightButtonPressEvent()
        elif self._ActiveButton == Qt.MidButton:
            self._Iren.MiddleButtonPressEvent()
canvas3d.py 文件源码 项目:dxf2gcode 作者: cnc-club 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def mouseMoveEvent(self, event):
        dx = event.pos().x() - self._lastPos.x()
        dy = event.pos().y() - self._lastPos.y()

        if self.isRotating:
            if event.buttons() == Qt.LeftButton:
                self.setXRotation(self.rotX - dy / 2)
                self.setYRotation(self.rotY + dx / 2)
            elif event.buttons() == Qt.RightButton:
                self.setXRotation(self.rotX - dy / 2)
                self.setZRotation(self.rotZ + dx / 2)
        elif self.isPanning:
            if event.buttons() == Qt.LeftButton:
                min_side = min(self.frameSize().width(), self.frameSize().height())
                dx, dy, dz = self.deRotate(dx, dy, 0)
                self.posX += dx / min_side
                self.posY += dy / min_side
                self.posZ += dz / min_side

        self._lastPos = event.pos()
        self.update()
gl.py 文件源码 项目:gpvdm 作者: roderickmackenzie 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def mouseMoveEvent(self,event):
            if  self.timer!=None:
                self.timer.stop()
                self.timer=None

            if self.lastPos==None:
                self.lastPos=event.pos()
            dx = event.x() - self.lastPos.x();
            dy = event.y() - self.lastPos.y();

            if event.buttons()==Qt.LeftButton:

                self.viewpoint.xRot =self.viewpoint.xRot + 1 * dy
                self.viewpoint.yRot =self.viewpoint.yRot + 1 * dx

            if event.buttons()==Qt.RightButton:
                self.viewpoint.x_pos =self.viewpoint.x_pos + 0.1 * dx
                self.viewpoint.y_pos =self.viewpoint.y_pos - 0.1 * dy


            self.lastPos=event.pos()
            self.setFocusPolicy(Qt.StrongFocus)
            self.setFocus()
            self.update()
LeftBarLineChart.py 文件源码 项目:pyqt5 作者: yurisnm 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def mouseDoubleClickEvent(self, event):
        if event.button() != Qt.LeftButton:
            super(TabBarPlus, self).mouseDoubleClickEvent(event)

        idx = self.currentIndex()
        ok = True
        self.input_dialog = QInputDialog()
        print(type(self.input_dialog.textEchoMode()))

        newName, ok = QInputDialog.getText(self, 'Mudar nome',
                                        'Novo nome:')

        if ok:
            self.parent().tables[idx].name = newName
            self.parent().series[idx].setName(newName)
            self.setTabText(idx, newName)
roundedButtonSet.py 文件源码 项目:defconQt 作者: trufont 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            for recordIndex, rect in self._optionsRects.items():
                if QRect(*rect).contains(event.pos()):
                    self._clickedIndex = recordIndex
                    self._oldSelection = self._selection
                    self._selection = {recordIndex}
                    if self._selectionMode > 1 and QApplication.keyboardModifiers(
                            ) & Qt.ShiftModifier:
                        shiftSelection = self._selection ^ self._oldSelection
                        if shiftSelection:
                            self._selection = shiftSelection
                    else:
                        self._selection |= self._oldSelection
                    break
            self.update()
        else:
            super().mousePressEvent(event)
roundedButtonSet.py 文件源码 项目:defconQt 作者: trufont 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def mouseReleaseEvent(self, event):
        if event.button() == Qt.LeftButton:
            clickedRect = self._optionsRects[self._clickedIndex]
            if QRect(*clickedRect).contains(event.pos()):
                self._selection = {self._clickedIndex}
                if self._selectionMode > 1 and QApplication.keyboardModifiers(
                        ) & Qt.ShiftModifier:
                    shiftSelection = self._selection ^ self._oldSelection
                    if shiftSelection:
                        self._selection = shiftSelection
                self.clicked.emit()
            else:
                self._selection = self._oldSelection
            self.update()
            del self._clickedIndex
            del self._oldSelection
        else:
            super().mouseReleaseEvent(event)
test_datawindow3.py 文件源码 项目:RRPam-WDS 作者: asselapathirana 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_pressing_select_diameter_button_will_select_items_with_current_diameter(self):
        self.create_a_new_project()
        from PyQt5.QtTest import QTest
        from PyQt5.QtCore import Qt
        self.aw.datawindow.ui.select_diameter_combobox.setCurrentIndex(3)
        self.assertEqual(self.aw.datawindow.ui.select_diameter_combobox.currentText(), '10.0')
        QTest.mouseClick(self.aw.datawindow.ui.select_diameter_button, Qt.LeftButton)
        nw = self.aw.networkmap.get_plot().get_selected_items()
        sel2 = [x.id_ for x in nw if (hasattr(x, "id_"))]
        dw = self.aw.datawindow.get_plot().get_selected_items()
        sel = [x.id_ for x in dw if (hasattr(x, "id_"))]
        self.assertSetEqual(set(sel), set(['12', '21', '111']))
        self.assertSetEqual(set(sel), set(sel2))
        self.aw.datawindow.ui.select_diameter_combobox.setCurrentIndex(2)
        self.assertEqual(self.aw.datawindow.ui.select_diameter_combobox.currentText(), '8.0')

        QTest.mouseClick(self.aw.datawindow.ui.select_diameter_button, Qt.LeftButton)
        nw = self.aw.networkmap.get_plot().get_selected_items()
        sel2 = [x.id_ for x in nw if (hasattr(x, "id_"))]
        dw = self.aw.datawindow.get_plot().get_selected_items()
        sel = [x.id_ for x in dw if (hasattr(x, "id_"))]
        self.assertSetEqual(set(sel), set(['113', '121']))
        time.sleep(1)
test_datawindow3.py 文件源码 项目:RRPam-WDS 作者: asselapathirana 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_pressing_copytoselection_button_will_make_selected_assets_have_current_group(self):
        self.create_a_new_project()
        from PyQt5.QtTest import QTest
        from PyQt5.QtCore import Qt
        self.test_pressing_select_diameter_button_will_select_items_with_current_diameter(
        )  # now we have 113 and 121 selected
        dw = self.aw.datawindow
        dw.ui.no_groups.setValue(4)
        dw.ui.grouptocopy.setCurrentText(dw._getgroupname(1))  # we have selected group G01
        self.assertEqual(dw.myplotitems['113'].my_group.currentText(),
                         dw._getgroupname(0))  # still the group of this item should be G00
        # now click the button
        QTest.mouseClick(dw.ui.copytoselection, Qt.LeftButton)
        self.assertEqual(dw.myplotitems['113'].my_group.currentText(),
                         dw._getgroupname(1))  # still the group of this item should be G00
        self.assertEqual(dw.myplotitems['121'].my_group.currentText(),
                         dw._getgroupname(1))  # still the group of this item should be G00
testdragndrop2.py 文件源码 项目:incubator-senssoft-userale-pyqt5 作者: apache 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def mousePressEvent(self, e):

        QPushButton.mousePressEvent(self, e)

        if e.button() == Qt.LeftButton:
            print('press')
__init__.py 文件源码 项目:gui_tool 作者: UAVCAN 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def add_crosshair(plot, render_measurements, color=Qt.gray):
    pen = mkPen(color=QColor(color), width=1)
    vline = InfiniteLine(angle=90, movable=False, pen=pen)
    hline = InfiniteLine(angle=0, movable=False, pen=pen)

    plot.addItem(vline, ignoreBounds=True)
    plot.addItem(hline, ignoreBounds=True)

    current_coordinates = None
    reference_coordinates = None

    def do_render():
        render_measurements(current_coordinates, reference_coordinates)

    def update(pos):
        nonlocal current_coordinates
        if plot.sceneBoundingRect().contains(pos):
            mouse_point = plot.getViewBox().mapSceneToView(pos)
            current_coordinates = mouse_point.x(), mouse_point.y()
            vline.setPos(mouse_point.x())
            hline.setPos(mouse_point.y())
            do_render()

    def set_reference(ev):
        nonlocal reference_coordinates
        if ev.button() == Qt.LeftButton and current_coordinates is not None:
            reference_coordinates = current_coordinates
            do_render()

    plot.scene().sigMouseMoved.connect(update)
    plot.scene().sigMouseClicked.connect(set_reference)
test.py 文件源码 项目:Pyquino 作者: kmolLin 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def mouseMoveEvent(self, event):
        dx = event.x() - self.lastPos.x()
        dy = event.y() - self.lastPos.y()

        if event.buttons() & Qt.LeftButton:
            self.setXRotation(self.xRot + 8 * dy)
            self.setYRotation(self.yRot + 8 * dx)
        elif event.buttons() & Qt.RightButton:
            self.setXRotation(self.xRot + 8 * dy)
            self.setZRotation(self.zRot + 8 * dx)

        self.lastPos = event.pos()
qttreepropertybrowser.py 文件源码 项目:QtPropertyBrowserV2.6-for-pyqt5 作者: theall 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def mousePressEvent(self, event):
        super(QtPropertyEditorView, self).mousePressEvent(event)
        item = self.itemAt(event.pos())

        if item:
            if ((item != self.m_editorPrivate.editedItem()) and (event.button() == Qt.LeftButton)
                    and (self.header().logicalIndexAt(event.pos().x()) == 1)
                    and ((item.flags() & (Qt.ItemIsEditable | Qt.ItemIsEnabled)) == (Qt.ItemIsEditable | Qt.ItemIsEnabled))):
                self.editItem(item, 1)
            elif (not self.m_editorPrivate.hasValue(item) and self.m_editorPrivate.markPropertiesWithoutValue() and not self.rootIsDecorated()):
                if (event.pos().x() + self.header().offset() < 20):
                    item.setExpanded(not item.isExpanded())

## ------------ QtPropertyEditorDelegate
qtpropertybrowserutils.py 文件源码 项目:QtPropertyBrowserV2.6-for-pyqt5 作者: theall 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def mousePressEvent(self, event):
        if (event.buttons() == Qt.LeftButton):
            self.m_checkBox.click()
            event.accept()
        else:
            super(QtBoolEdit, self).mousePressEvent(event)
QVTKRenderWindowInteractor.py 文件源码 项目:mhri 作者: mhri 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def mouseReleaseEvent(self, ev):
        ctrl, shift = self._GetCtrlShift(ev)
        self._Iren.SetEventInformationFlipY(ev.x(), ev.y(),
                                            ctrl, shift, chr(0), 0, None)

        if self._ActiveButton == Qt.LeftButton:
            self._Iren.LeftButtonReleaseEvent()
        elif self._ActiveButton == Qt.RightButton:
            self._Iren.RightButtonReleaseEvent()
        elif self._ActiveButton == Qt.MidButton:
            self._Iren.MiddleButtonReleaseEvent()
sheetview.py 文件源码 项目:pyree-old 作者: DrLuke 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def mousePressEvent(self, event):
            if event.button() == Qt.LeftButton:
                if self.iodir == "output":
                    self.newbezier = Node.io.BezierCurve(self, None)
                elif self.iodir == "input":
                    self.newbezier = Node.io.BezierCurve(None, self)

                if self.newbezier is not None:
                    self.newbezier.update(QPointF(event.pos() + self.pos() + self.parent.pos()))

                self.parent.parent.scene.addItem(self.newbezier)
            elif event.button() == Qt.RightButton:
                self.delAllBezier()
sheetview.py 文件源码 项目:pyree-old 作者: DrLuke 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def mouseDoubleClickEvent(self, event):
        if not self.emptySheet:
            if event.button() == Qt.LeftButton:
                items = self.scene.selectedItems()
                if len(items) == 1:
                    item = items[0]
                    if isinstance(item, Node):
                        if item.nodedata.settingsDialog is not None:    # TODO: Maybe check if it's subclass of QDialog
                            dialog = item.nodedata.settingsDialog(item.extraNodeData, self, self.sheethandler)
                            if dialog.exec():
                                item.extraNodeData = dialog.data
mpvQC.py 文件源码 项目:mpvQC 作者: Frechdachs 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def mousePressEvent(self, event):
        """ Disable stupid dragging feature """
        if event.button() == Qt.LeftButton:
            newcursor = self.cursorForPosition(event.pos())
            self.setTextCursor(newcursor)
            event.accept()
        super(RegularTextEdit, self).mousePressEvent(event)
mpvQC.py 文件源码 项目:mpvQC 作者: Frechdachs 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def mousePressEvent(self, event):
        """ Disable stupid dragging feature """
        if event.button() == Qt.LeftButton:
            newcursor = self.cursorForPosition(event.pos())
            self.setTextCursor(newcursor)
            event.accept()
        super(CommentTextEdit, self).mousePressEvent(event)
mpvQC.py 文件源码 项目:mpvQC 作者: Frechdachs 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def clickedOnCommentListView(index):
    if (index.column() == 0
            and QApplication.mouseButtons() == Qt.LeftButton):
        try:
            timestamp = commentmodel.item(index.row(), 0).text()
            seconds = timestampToSeconds(timestamp)
            mp.command("seek", seconds, "absolute+exact")
        except SystemError:
            pass
mpvQC.py 文件源码 项目:mpvQC 作者: Frechdachs 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def doubleClickedOnCommentListView(index):
    if (index.column() == 0
            and QApplication.mouseButtons() == Qt.LeftButton):
        TimestampDialog(mainwindow, index).exec_()
    if (index.column() == 1
            and QApplication.mouseButtons() == Qt.LeftButton):
        CommentTypeDialog(mainwindow, index).exec_()
test_{{cookiecutter.application_name}}.py 文件源码 项目:cookiecutter-pyqt5 作者: mandeep 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_open_file(window, qtbot, mock):
    """Test the Open File item of the File submenu.

    Qtbot clicks on the file sub menu and then navigates to the Open File item. Mock creates
    an object to be passed to the QFileDialog.
    """
    qtbot.mouseClick(window.file_sub_menu, Qt.LeftButton)
    qtbot.keyClick(window.file_sub_menu, Qt.Key_Down)
    mock.patch.object(QFileDialog, 'getOpenFileName', return_value=('', ''))
    qtbot.keyClick(window.file_sub_menu, Qt.Key_Enter)
test_{{cookiecutter.application_name}}.py 文件源码 项目:cookiecutter-pyqt5 作者: mandeep 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_about_dialog(window, qtbot, mock):
    """Test the About item of the Help submenu.

    Qtbot clicks on the help sub menu and then navigates to the About item. Mock creates
    a QDialog object to be used for the test.
    """
    qtbot.mouseClick(window.help_sub_menu, Qt.LeftButton)
    qtbot.keyClick(window.help_sub_menu, Qt.Key_Down)
    mock.patch.object(QDialog, 'exec_', return_value='accept')
    qtbot.keyClick(window.help_sub_menu, Qt.Key_Enter)
videoslider.py 文件源码 项目:vidcutter 作者: ozmartian 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def eventFilter(self, obj: QObject, event: QMouseEvent) -> bool:
        if event.type() == QEvent.MouseButtonRelease and event.button() == Qt.LeftButton:
            if self.parent.mediaAvailable and self.isEnabled():
                newpos = QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), event.x() - self.offset,
                                                        self.width() - (self.offset * 2))
                self.setValue(newpos)
                self.parent.setPosition(newpos)
                self.parent.parent.mousePressEvent(event)
        return super(VideoSlider, self).eventFilter(obj, event)
notifications.py 文件源码 项目:vidcutter 作者: ozmartian 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def mousePressEvent(self, event: QMouseEvent):
        if event.button() == Qt.LeftButton:
            self.fadeOut()

    # noinspection PyTypeChecker
canvas3d.py 文件源码 项目:dxf2gcode 作者: cnc-club 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def mousePressEvent(self, event):
        if self.isPanning or self.isRotating:
            self.setCursor(Qt.ClosedHandCursor)
        elif event.button() == Qt.LeftButton:
            clicked, offset, tol = self.getClickedDetails(event)
            xyForZ = {}
            for shape in self.shapes:
                hit = False
                z = shape.axis3_start_mill_depth
                if z not in xyForZ:
                    xyForZ[z] = self.determineSelectedPosition(clicked, z, offset)
                hit |= shape.isHit(xyForZ[z], tol)

                if not hit:
                    z = shape.axis3_mill_depth
                    if z not in xyForZ:
                        xyForZ[z] = self.determineSelectedPosition(clicked, z, offset)
                    hit |= shape.isHit(xyForZ[z], tol)

                if self.isMultiSelect and shape.selected:
                    hit = not hit

                if hit != shape.selected:
                    g.window.TreeHandler.updateShapeSelection(shape, hit)

                shape.selected = hit

            self.update()
        self._lastPos = event.pos()
canvas3d.py 文件源码 项目:dxf2gcode 作者: cnc-club 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def mouseReleaseEvent(self, event):
        if event.button() == Qt.LeftButton or event.button() == Qt.RightButton:
            if self.isPanning:
                self.setCursor(Qt.OpenHandCursor)
            elif self.isRotating:
                self.setCursor(Qt.PointingHandCursor)
test_application.py 文件源码 项目:Mausoleum 作者: mandeep 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_create_page_failure(window, qtbot):
    """Test tomb creation with key passwords that don't match."""
    button = window.create_page.create_button
    window.create_page.key_password.setText('1')
    window.create_page.confirm_password.setText('2')
    qtbot.mouseClick(button, Qt.LeftButton)
    assert window.create_page.message.text() == 'Key Passwords Do Not Match'
test_application.py 文件源码 项目:Mausoleum 作者: mandeep 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def test_create_page(window, qtbot, name, key, password):
    """Test tomb creation and tomb opening."""
    window.create_page.tomb_name.setText(name)
    window.create_page.key_name.setText(key)
    window.create_page.key_password.setText(password)
    window.create_page.confirm_password.setText(password)
    window.create_page.random_checkbox.setChecked(True)
    window.create_page.open_checkbox.setChecked(True)
    button = window.create_page.create_button
    qtbot.mouseClick(button, Qt.LeftButton)
    assert window.create_page.message.text() == 'Tomb Opened Successfully'
test_application.py 文件源码 项目:Mausoleum 作者: mandeep 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_close_page_close(window, qtbot):
    """Test the Close All Tombs button on the Close tab."""
    window.pages.setCurrentIndex(2)
    button = window.close_page.close_all_button
    qtbot.mouseClick(button, Qt.LeftButton)
test_application.py 文件源码 项目:Mausoleum 作者: mandeep 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_open_page(window, qtbot, name, key, password):
    """Test tomb opening on the Open tab."""
    window.pages.setCurrentIndex(1)
    window.open_page.tomb_path.setText(name)
    window.open_page.key_path.setText(key)
    window.open_page.key_password.setText(password)
    button = window.open_page.open_button
    qtbot.mouseClick(button, Qt.LeftButton)
    assert window.open_page.message.text() == 'Tomb Opened Successfully'


问题


面经


文章

微信
公众号

扫码关注公众号