当前位置: 首页>>代码示例>>Python>>正文


Python QEvent.MouseButtonPress方法代码示例

本文整理汇总了Python中PyQt5.QtCore.QEvent.MouseButtonPress方法的典型用法代码示例。如果您正苦于以下问题:Python QEvent.MouseButtonPress方法的具体用法?Python QEvent.MouseButtonPress怎么用?Python QEvent.MouseButtonPress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtCore.QEvent的用法示例。


在下文中一共展示了QEvent.MouseButtonPress方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: editorEvent

# 需要导入模块: from PyQt5.QtCore import QEvent [as 别名]
# 或者: from PyQt5.QtCore.QEvent import MouseButtonPress [as 别名]
def editorEvent(self, event, model, option, index):
        ''' 
        Handle mouse events in cell.
        On left button release in this cell, call model's setData() method,
            wherein the button clicked action should be handled.
        Currently, the value supplied to setData() is the button text, but this is arbitrary.
        '''
        if event.button() == Qt.LeftButton:
            if event.type() == QEvent.MouseButtonPress:
                if option.rect.contains(event.pos()):
                    self._isMousePressed = True
                    return True
            elif event.type() == QEvent.MouseButtonRelease:
                self._isMousePressed = False
                if option.rect.contains(event.pos()):
                    model.setData(index, self.text, Qt.EditRole)  # Model should handle button click action in its setData() method.
                    return True
        return False 
开发者ID:aseylys,项目名称:KStock,代码行数:20,代码来源:PushButtonDelegateQt.py

示例2: handleEvent

# 需要导入模块: from PyQt5.QtCore import QEvent [as 别名]
# 或者: from PyQt5.QtCore.QEvent import MouseButtonPress [as 别名]
def handleEvent(self, event):
        if event.type() == QEvent.MouseButtonPress:
            ex, ey = self._normalizeCoordinates(event.windowPos().x(), event.windowPos().y())
            e = MouseEvent(MouseEvent.MousePressEvent, ex, ey, self._x, self._y, self._qtButtonsToButtonList(event.buttons()))
            self._x = ex
            self._y = ey
            self.event.emit(e)
        elif event.type() == QEvent.MouseMove:
            ex, ey = self._normalizeCoordinates(event.windowPos().x(), event.windowPos().y())
            e = MouseEvent(MouseEvent.MouseMoveEvent, ex, ey, self._x, self._y, self._qtButtonsToButtonList(event.buttons()))
            self._x = ex
            self._y = ey
            self.event.emit(e)
        elif event.type() == QEvent.MouseButtonRelease:
            ex, ey = self._normalizeCoordinates(event.windowPos().x(), event.windowPos().y())
            e = MouseEvent(MouseEvent.MouseReleaseEvent, ex, ey, self._x, self._y, self._qtButtonsToButtonList(event.button()))
            self._x = ex
            self._y = ey
            self.event.emit(e)
        elif event.type() == QEvent.Wheel:
            delta = event.angleDelta()
            e = WheelEvent(delta.x(), delta.y())
            self.event.emit(e) 
开发者ID:Ultimaker,项目名称:Uranium,代码行数:25,代码来源:QtMouseDevice.py

示例3: _click_fake_event

# 需要导入模块: from PyQt5.QtCore import QEvent [as 别名]
# 或者: from PyQt5.QtCore.QEvent import MouseButtonPress [as 别名]
def _click_fake_event(self, click_target: usertypes.ClickTarget,
                          button: Qt.MouseButton = Qt.LeftButton) -> None:
        """Send a fake click event to the element."""
        pos = self._mouse_pos()

        log.webelem.debug("Sending fake click to {!r} at position {} with "
                          "target {}".format(self, pos, click_target))

        target_modifiers = {
            usertypes.ClickTarget.normal: Qt.NoModifier,
            usertypes.ClickTarget.window: Qt.AltModifier | Qt.ShiftModifier,
            usertypes.ClickTarget.tab: Qt.ControlModifier,
            usertypes.ClickTarget.tab_bg: Qt.ControlModifier,
        }
        if config.val.tabs.background:
            target_modifiers[usertypes.ClickTarget.tab] |= Qt.ShiftModifier
        else:
            target_modifiers[usertypes.ClickTarget.tab_bg] |= Qt.ShiftModifier

        modifiers = typing.cast(Qt.KeyboardModifiers,
                                target_modifiers[click_target])

        events = [
            QMouseEvent(QEvent.MouseMove, pos, Qt.NoButton, Qt.NoButton,
                        Qt.NoModifier),
            QMouseEvent(QEvent.MouseButtonPress, pos, button, button,
                        modifiers),
            QMouseEvent(QEvent.MouseButtonRelease, pos, button, Qt.NoButton,
                        modifiers),
        ]

        for evt in events:
            self._tab.send_event(evt)

        QTimer.singleShot(0, self._move_text_cursor) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:37,代码来源:webelem.py

示例4: __init__

# 需要导入模块: from PyQt5.QtCore import QEvent [as 别名]
# 或者: from PyQt5.QtCore.QEvent import MouseButtonPress [as 别名]
def __init__(self, tab, *, parent=None):
        super().__init__(parent)
        self._tab = tab
        self._handlers = {
            QEvent.MouseButtonPress: self._handle_mouse_press,
            QEvent.MouseButtonRelease: self._handle_mouse_release,
            QEvent.Wheel: self._handle_wheel,
            QEvent.KeyRelease: self._handle_key_release,
        }
        self._ignore_wheel_event = False
        self._check_insertmode_on_release = False 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:13,代码来源:eventfilter.py

示例5: eventFilter

# 需要导入模块: from PyQt5.QtCore import QEvent [as 别名]
# 或者: from PyQt5.QtCore.QEvent import MouseButtonPress [as 别名]
def eventFilter(self, _obj: QObject, event: QEvent) -> bool:
        """Enter insert mode if the inspector is clicked."""
        if event.type() == QEvent.MouseButtonPress:
            modeman.enter(self._win_id, usertypes.KeyMode.insert,
                          reason='Inspector clicked', only_if_normal=True)
        return False 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:8,代码来源:inspector.py

示例6: test_widget_notes_mark_event

# 需要导入模块: from PyQt5.QtCore import QEvent [as 别名]
# 或者: from PyQt5.QtCore.QEvent import MouseButtonPress [as 别名]
def test_widget_notes_mark_event(qtbot):

    w = Wonambi()
    qtbot.addWidget(w)

    w.info.open_dataset(str(gui_file))
    channel_make_group(w)
    w.channels.button_apply.click()
    w.channels.new_group(test_name='eog')
    w.notes.update_notes(annot_psg_path)
    w.traces.Y_wider()
    w.traces.Y_wider()
    w.traces.action['cross_chan_mrk'].setChecked(True)
    w.traces.go_to_epoch(test_text_str='23:34:45')

    w.notes.new_eventtype(test_type_str='spindle')
    w.notes.action['new_event'].setChecked(True)
    w.notes.add_event('spindle', (24293.01, 24294.65), 'EEG Pz-Oz (scalp)')

    screenshot(w, 'notes_14_mark_event.png')

    w.notes.add_event('spindle', (24288.01, 24288.90), 'EEG Fpz-Cz (scalp)')
    w.notes.add_event('spindle', (24297.5, 24298.00), 'EEG Fpz-Cz (scalp)')

    screenshot(w, 'notes_20_mark_short_event.png')

    pos = w.traces.mapFromScene(QPointF(24294, 75))
    mouseclick = QMouseEvent(QEvent.MouseButtonPress, pos,
                             Qt.LeftButton, Qt.NoButton, Qt.NoModifier)
    w.traces.mousePressEvent(mouseclick)

    screenshot(w, 'notes_15_highlight_event.png')

    w.notes.delete_eventtype(test_type_str='spindle')

    w.close() 
开发者ID:wonambi-python,项目名称:wonambi,代码行数:38,代码来源:test_widget_notes.py

示例7: eventFilter

# 需要导入模块: from PyQt5.QtCore import QEvent [as 别名]
# 或者: from PyQt5.QtCore.QEvent import MouseButtonPress [as 别名]
def eventFilter(self, obj, event):
# the next prevents correct setSelection on Windows
#        if event.type() == QEvent.FocusIn:
#            self.setSelection(self.currentIndex())
        if event.type() == QEvent.MouseButtonPress:
            self.updateMenu()
#            return True # stops processing # popup not drawn if this line is added
#        return super(RoastsComboBox, self).eventFilter(obj, event) # this seems to slow down things on Windows and not necessary anyhow
        return False # cont processing

    # the first entry is always just the current text edit line 
开发者ID:artisan-roaster-scope,项目名称:artisan,代码行数:13,代码来源:roast_properties.py

示例8: mousePressEvent

# 需要导入模块: from PyQt5.QtCore import QEvent [as 别名]
# 或者: from PyQt5.QtCore.QEvent import MouseButtonPress [as 别名]
def mousePressEvent(self, event):
        """
        Select misspelled word after right click
        otherwise left clik + right click is needed.

        Originally from John Schember spellchecker
        """
        if event.button() == Qt.RightButton:
            # Rewrite the mouse event to a left button event so the cursor is
            # moved to the location of the pointer.
            event = QMouseEvent(QEvent.MouseButtonPress, event.pos(),
                Qt.LeftButton, Qt.LeftButton, Qt.NoModifier)
        QTextEdit.mousePressEvent(self, event) 
开发者ID:zdenop,项目名称:lector,代码行数:15,代码来源:textwidget.py

示例9: event

# 需要导入模块: from PyQt5.QtCore import QEvent [as 别名]
# 或者: from PyQt5.QtCore.QEvent import MouseButtonPress [as 别名]
def event(self, event):
        if not self.initialized:
            return super(BlipDriver, self).event(event)

        self.makeCurrent()
        if event.type() in [QEvent.MouseMove, QEvent.MouseButtonPress, QEvent.MouseButtonRelease]:
            px = 2.0 * (event.x()) / self.width - 1.0
            py = 10.0 * (self.height - event.y()) / self.height - 1.0

        if event.type() == QEvent.MouseButtonPress and event.button() & Qt.LeftButton:
            self.btn_pressed, _ = check_knob(px, py)
            if self.btn_pressed is not None:
                self.drag_start = event.x(), event.y()
                QTimer.singleShot(100, self.updateAPValues)

        elif event.type() == QEvent.MouseButtonRelease and event.button() & Qt.LeftButton:
            # print px, py
            self.btn_pressed = None
            col_triangles = 6 * [255, 255, 255, 180]
            update_buffer(self.updown.colorbuf, np.array(col_triangles, dtype=np.uint8))
            # MCP button clicked?
            name, idx = check_btn(px, py)
            if name is not None:
                self.btn_state[idx] = not self.btn_state[idx]

            btn_color = []
            for b in self.btn_state:
                btn_color += 24 * [255] if b else 24 * [0]
            update_buffer(self.btn_leds.colorbuf, np.array(btn_color, dtype=np.uint8))
        elif event.type() == QEvent.MouseMove:
            if event.buttons() & Qt.LeftButton and self.btn_pressed is not None:
                self.rate = float(self.drag_start[1] - event.y()) / self.height
                if self.rate > 1e-2:
                    col_triangles = 3 * [255, 140, 0, 255] + 3 * [255, 255, 255, 180]
                elif self.rate < 1e-2:
                    col_triangles = 3 * [255, 255, 255, 180] + 3 * [255, 140, 0, 255]
                else:
                    col_triangles = 6 * [255, 255, 255, 180]
                update_buffer(self.updown.colorbuf, np.array(col_triangles, dtype=np.uint8))
                return True
            # Mouse-over for knobs
            name, self.updownpos = check_knob(px, py)

            # ismcp = float(self.height - event.y()) / self.height <= 0.2

        return super(BlipDriver, self).event(event) 
开发者ID:TUDelft-CNS-ATM,项目名称:bluesky,代码行数:48,代码来源:blipdriver.py


注:本文中的PyQt5.QtCore.QEvent.MouseButtonPress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。