當前位置: 首頁>>代碼示例>>Python>>正文


Python QEvent.KeyPress方法代碼示例

本文整理匯總了Python中PyQt5.QtCore.QEvent.KeyPress方法的典型用法代碼示例。如果您正苦於以下問題:Python QEvent.KeyPress方法的具體用法?Python QEvent.KeyPress怎麽用?Python QEvent.KeyPress使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtCore.QEvent的用法示例。


在下文中一共展示了QEvent.KeyPress方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _handle_keyrelease

# 需要導入模塊: from PyQt5.QtCore import QEvent [as 別名]
# 或者: from PyQt5.QtCore.QEvent import KeyPress [as 別名]
def _handle_keyrelease(self, event: QKeyEvent) -> bool:
        """Handle filtering of KeyRelease events.

        Args:
            event: The KeyPress to examine.

        Return:
            True if event should be filtered, False otherwise.
        """
        # handle like matching KeyPress
        keyevent = KeyEvent.from_event(event)
        if keyevent in self._releaseevents_to_pass:
            self._releaseevents_to_pass.remove(keyevent)
            filter_this = False
        else:
            filter_this = True
        if self.mode != usertypes.KeyMode.insert:
            log.modes.debug("filter: {}".format(filter_this))
        return filter_this 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:21,代碼來源:modeman.py

示例2: handle_event

# 需要導入模塊: from PyQt5.QtCore import QEvent [as 別名]
# 或者: from PyQt5.QtCore.QEvent import KeyPress [as 別名]
def handle_event(self, event: QEvent) -> bool:
        """Filter all events based on the currently set mode.

        Also calls the real keypress handler.

        Args:
            event: The KeyPress to examine.

        Return:
            True if event should be filtered, False otherwise.
        """
        handlers = {
            QEvent.KeyPress: self._handle_keypress,
            QEvent.KeyRelease: self._handle_keyrelease,
            QEvent.ShortcutOverride:
                functools.partial(self._handle_keypress, dry_run=True),
        }  # type: Mapping[QEvent.Type, Callable[[QKeyEvent], bool]]
        handler = handlers[event.type()]
        return handler(cast(QKeyEvent, event)) 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:21,代碼來源:modeman.py

示例3: eventFilter

# 需要導入模塊: from PyQt5.QtCore import QEvent [as 別名]
# 或者: from PyQt5.QtCore.QEvent import KeyPress [as 別名]
def eventFilter(self, obj, e):
        if obj == self.command and e.type() == QEvent.KeyPress:
            history = self.device.history
            if e.modifiers() & Qt.ControlModifier:
                if e.key() == Qt.Key_H:
                    d = DeviceConsoleHistory(self.device.env.devices)
                    if d.exec_() == QDialog.Accepted:
                        self.command.setText(d.command)

                elif len(history) > 0:
                    if e.key() == Qt.Key_E:
                        self.command.setText(history[0])

                    if e.key() == Qt.Key_Down:
                        self.command.completer().setModel(QStringListModel(history))
                        self.command.setText(' ')
                        self.command.completer().complete()
            return False

        return QDockWidget.eventFilter(self, obj, e) 
開發者ID:jziolkowski,項目名稱:tdm,代碼行數:22,代碼來源:Console.py

示例4: test_surrogates

# 需要導入模塊: from PyQt5.QtCore import QEvent [as 別名]
# 或者: from PyQt5.QtCore.QEvent import KeyPress [as 別名]
def test_surrogates(key, modifiers, text, expected):
    evt = QKeyEvent(QKeyEvent.KeyPress, key, modifiers, text)
    assert str(keyutils.KeyInfo.from_event(evt)) == expected 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:5,代碼來源:test_keyutils.py

示例5: test_append_event

# 需要導入模塊: from PyQt5.QtCore import QEvent [as 別名]
# 或者: from PyQt5.QtCore.QEvent import KeyPress [as 別名]
def test_append_event(self, old, key, modifiers, text, expected):
        seq = keyutils.KeySequence.parse(old)
        event = QKeyEvent(QKeyEvent.KeyPress, key, modifiers, text)
        new = seq.append_event(event)
        assert new == keyutils.KeySequence.parse(expected) 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:7,代碼來源:test_keyutils.py

示例6: test_append_event_invalid

# 需要導入模塊: from PyQt5.QtCore import QEvent [as 別名]
# 或者: from PyQt5.QtCore.QEvent import KeyPress [as 別名]
def test_append_event_invalid(self, key):
        seq = keyutils.KeySequence()
        event = QKeyEvent(QKeyEvent.KeyPress, key, Qt.NoModifier, '')
        with pytest.raises(keyutils.KeyParseError):
            seq.append_event(event) 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:7,代碼來源:test_keyutils.py

示例7: test_key_info_from_event

# 需要導入模塊: from PyQt5.QtCore import QEvent [as 別名]
# 或者: from PyQt5.QtCore.QEvent import KeyPress [as 別名]
def test_key_info_from_event():
    ev = QKeyEvent(QEvent.KeyPress, Qt.Key_A, Qt.ShiftModifier, 'A')
    info = keyutils.KeyInfo.from_event(ev)
    assert info.key == Qt.Key_A
    assert info.modifiers == Qt.ShiftModifier 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:7,代碼來源:test_keyutils.py

示例8: to_event

# 需要導入模塊: from PyQt5.QtCore import QEvent [as 別名]
# 或者: from PyQt5.QtCore.QEvent import KeyPress [as 別名]
def to_event(self, typ: QEvent.Type = QEvent.KeyPress) -> QKeyEvent:
        """Get a QKeyEvent from this KeyInfo."""
        return QKeyEvent(typ, self.key, self.modifiers, self.text()) 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:5,代碼來源:keyutils.py

示例9: __init__

# 需要導入模塊: from PyQt5.QtCore import QEvent [as 別名]
# 或者: from PyQt5.QtCore.QEvent import KeyPress [as 別名]
def __init__(self, parent: QObject = None) -> None:
        super().__init__(parent)
        self._activated = True
        self._handlers = {
            QEvent.KeyPress: self._handle_key_event,
            QEvent.KeyRelease: self._handle_key_event,
            QEvent.ShortcutOverride: self._handle_key_event,
        } 
開發者ID:qutebrowser,項目名稱:qutebrowser,代碼行數:10,代碼來源:eventfilter.py

示例10: eventFilter

# 需要導入模塊: from PyQt5.QtCore import QEvent [as 別名]
# 或者: from PyQt5.QtCore.QEvent import KeyPress [as 別名]
def eventFilter(self, source, event):
        if event.type() == QEvent.KeyPress:
            if event.key():
                # show new keys in window
                self.capturedKeyLabel.setText(str(QKeySequence(event.modifiers() | event.key()).toString()))
        return super(KeyCapturingWindow, self).eventFilter(source, event) 
開發者ID:persepolisdm,項目名稱:persepolis,代碼行數:8,代碼來源:setting.py

示例11: eventFilter

# 需要導入模塊: from PyQt5.QtCore import QEvent [as 別名]
# 或者: from PyQt5.QtCore.QEvent import KeyPress [as 別名]
def eventFilter(self, obj, event):
        if obj == self.edtCommand:
            if event.type() == QEvent.KeyPress:
                if event.key() == Qt.Key_Up:
                    self.prev_command()
                    return True
                elif event.key() == Qt.Key_Down:
                    self.next_command()
                    return True
            return False
        else:
            return super().eventFilter(obj, event) 
開發者ID:Bertrand256,項目名稱:dash-masternode-tool,代碼行數:14,代碼來源:cmd_console_dlg.py

示例12: handleEvent

# 需要導入模塊: from PyQt5.QtCore import QEvent [as 別名]
# 或者: from PyQt5.QtCore.QEvent import KeyPress [as 別名]
def handleEvent(self, event):
        if event.type() == QEvent.KeyPress:
            e = KeyEvent(KeyEvent.KeyPressEvent, self._qtKeyToUMKey(event.key()))
            self.event.emit(e)
        elif event.type() == QEvent.KeyRelease:
            e = KeyEvent(KeyEvent.KeyReleaseEvent, self._qtKeyToUMKey(event.key()))
            self.event.emit(e) 
開發者ID:Ultimaker,項目名稱:Uranium,代碼行數:9,代碼來源:QtKeyDevice.py

示例13: eventFilter

# 需要導入模塊: from PyQt5.QtCore import QEvent [as 別名]
# 或者: from PyQt5.QtCore.QEvent import KeyPress [as 別名]
def eventFilter(self, source, evt):
    t = evt.type()
    if t == QEvent.Wheel:
      self.new_entry_flag = True
      self.mouse_scroll_event(evt)
      return True
    elif t == QEvent.KeyPress:
      self.new_entry_flag = True
      if evt.key() == QtCore.Qt.Key_Return:
        self.update_entry(evt)
        return True
    return False 
開發者ID:lutusp,項目名稱:PLSDR,代碼行數:14,代碼來源:MyTextEntry.py

示例14: eventFilter

# 需要導入模塊: from PyQt5.QtCore import QEvent [as 別名]
# 或者: from PyQt5.QtCore.QEvent import KeyPress [as 別名]
def eventFilter(self, receiver, event):
        # catch up/down arrow key presses in hosts table
        if event.type() == QEvent.KeyPress and receiver in self.hosts_table_views:
            return self.filterKeyPressInHostsTableView(event.key(), receiver)
        elif event.type() == QEvent.Close and receiver == self.main_window:
            event.ignore()
            self.view.appExit()
            return True
        else:
            parent = super(MyEventFilter, self)
            return parent.eventFilter(receiver, event)  # normal event processing 
開發者ID:GoVanguard,項目名稱:legion,代碼行數:13,代碼來源:eventfilter.py

示例15: simulateKeyPress

# 需要導入模塊: from PyQt5.QtCore import QEvent [as 別名]
# 或者: from PyQt5.QtCore.QEvent import KeyPress [as 別名]
def simulateKeyPress(self, key_event):
        self.mock_event.type = Mock(return_value=QEvent.KeyPress)
        self.mock_event.key = Mock(return_value=key_event) 
開發者ID:GoVanguard,項目名稱:legion,代碼行數:5,代碼來源:test_eventfilter.py


注:本文中的PyQt5.QtCore.QEvent.KeyPress方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。