示例#1
0
 def keyPressEvent(self, event):
     if event.type() == QEvent.KeyPress:
         key_event = QKeyEvent(event)
         if(key_event.key() == Qt.Key_Down
           or key_event.key() == Qt.Key_Up):
             return self.list_widget.keyPressEvent(event)
         elif((event.key() == Qt.Key_Enter  or  event.key() == Qt.Key_Return)
                 and self.list_widget.currentItem()>=0):
             self.hide()
             self.event_selected_command(str(self.full_command.toPlainText()))
     return super(CommandWindow, self).keyPressEvent(event)
示例#2
0
    def keyPressEvent(self, event: QKeyEvent):
        if event.modifiers() and Qt.ControlModifier:
            handled = False
        if event.key() == Qt.Key_B:
            self.toggleTextBold()  # bolden text
            handled = True
        elif event.key() == Qt.Key_I:
            self.toggleTextItalics()  # italicise text
            handled = True
            print("Ctrl+I")

        if handled:
            event.accept()
            return
        else:
            QTextEdit.keyPressEvent(self.currentPage, event)
示例#3
0
文件: main.py 项目: selam/ublog
    def eventFilter(self, obj, event):
        if isinstance(obj, KTextEdit):
            if event.type() == QEvent.KeyPress:
                key_event = QKeyEvent(event)
                key = key_event.key()
                if (key_event.modifiers() == Qt.ControlModifier) and (key == Qt.Key_Enter or key == Qt.Key_Return):
                    self.update_status()
                    return True

                safe_keys = [Qt.Key_Delete, Qt.Key_Backspace,
                             Qt.Key_Up, Qt.Key_Down,
                             Qt.Key_Right, Qt.Key_Left,
                             Qt.Key_Home, Qt.Key_End]

                if key not in safe_keys:
                    if self.status_edit.nativeWidget().toPlainText().length() >= 140:
                        return True
            return False

        elif isinstance(obj, KTabBar) and event.type() == QEvent.MouseButtonPress:
            self.scroll_widget.ensureItemVisible(self.main_frame)
            self.status_edit.setFocus()
            return False
        else:
            return self.applet.eventFilter(obj, event)
示例#4
0
    def appendQKeyEvent(self, keyEvent: QtGui.QKeyEvent):
        """
        Append another key to the key sequence represented by this object.

        |Args|

        * ``keyEvent`` (**QKeyEvent**): the key to add.

        |Returns|

        **None**

        |Raises|

        * **QtmacsArgumentError** if at least one argument has an invalid type.
        """
        # Store the QKeyEvent.
        self.keylistKeyEvent.append(keyEvent)

        # Convenience shortcuts.
        mod = keyEvent.modifiers()
        key = keyEvent.key()

        # Add the modifier and key to the list. The modifier is a
        # QFlag structure and must by typecast to an integer to avoid
        # difficulties with the hashing in the ``match`` routine of
        # the ``QtmacsKeymap`` object.
        self.keylistQtConstants.append((int(mod), key))
示例#5
0
文件: miow.py 项目: jleahred/miow
    def notify(self, receiver, event):
        if event.type() == QEvent.KeyPress:
            key_event = QKeyEvent(event)
            key_text = PyQt4.QtGui.QKeySequence(key_event.key() | key_event.modifiers().__int__()).toString()
            text = key_event.text()

            if (key_text, text) == KEY_STOP_RECORDING and not self.recording:
                self.reproduce_keys(self._keys_recorded)
            elif (key_text, text) == KEY_STOP_RECORDING and self.recording:
                self.recording = False
            elif self.recording:
                self._keys_recorded.append((key_text, unicode(text)))

            if (key_text, text) == KEY_START_RECORDING:
                self.recording = True
                self._keys_recorded = []

            # ==============================================================================
            #             key = {
            #                 "key": key_event.key(),
            #                 "modifiers": int(key_event.modifiers()),
            #                 "text": key_event.text(),
            #                 "autorepeat": key_event.isAutoRepeat(),
            #                 "autorepeat": key_event.isAutoRepeat(),
            #                 "count": key_event.count()
            #             }
            #             print key
            # ==============================================================================
            # ==============================================================================
            #         if event.type() == QEvent.KeyPress:
            #             key_event = QKeyEvent(event)
            #             ker = QKeyEvent(QEvent.KeyPress,
            #                             key_event.key(),
            #                             key_event.modifiers(),
            #                             key_event.text(),
            #                             key_event.isAutoRepeat(),
            #                             key_event.count())
            #             super(MiowApplication, self).notify(receiver, ker)
            # ==============================================================================
            for key_as_text, method in self.keys_map:
                if key_as_text == (key_text, text):
                    replace = method(key_event, key_as_text)
                    if replace == None:
                        return True
                    elif replace == False:
                        return super(MiowApplication, self).notify(receiver, event)
                    else:
                        return self.notify(receiver, replace)

        return super(MiowApplication, self).notify(receiver, event)
示例#6
0
 def keyPressEvent(self, event):
     keyEvent = QKeyEvent(event)
     if keyEvent.key() == QtCore.Qt.Key_Enter or keyEvent.key() == QtCore.Qt.Key_Return:
         self.qmc.draw_all()
     if keyEvent.key() == QtCore.Qt.Key_0:
         self.draw_all()
示例#7
0
 def f2(e: QtGui.QKeyEvent):
     if e.key() == QtCore.Qt.Key_Delete:
         self.delete_test()
示例#8
0
 def keyPressEvent(self, e: QKeyEvent):
     print('here')
     if e.key() == Qt.Key_Delete:
         self.delete_selected_elements()
         self.repaint()
示例#9
0
 def keyPressEvent(self, e: QtGui.QKeyEvent):
     if e.key() == QtCore.Qt.Key_Delete:
         self.delete_row(self.currentRow())
 def keyPressEvent(self, event):
     keyEvent = QKeyEvent(event)
     if keyEvent.key() == Qt.Key_Enter or keyEvent.key() == Qt.Key_Return:
         if not self.ensureBtn.isHidden():
             self.slotCheckPassWord()
示例#11
0
 def keyPressEvent(self, event):
     keyEvent = QKeyEvent(event)
     if keyEvent.key() == QtCore.Qt.Key_Enter or keyEvent.key() == QtCore.Qt.Key_Return:
         self.qmc.get_value()
     if keyEvent.key() == QtCore.Qt.Key_0:
         self.get_value()
示例#12
0
 def keyPressEvent(self, event): 
     keyEvent = QKeyEvent(event)
     if keyEvent.key() == Qt.Key_Enter or keyEvent.key() == Qt.Key_Return:
         self.run()
示例#13
0
 def keyPressEvent(self, e: QKeyEvent):
     print('here')
     if e.key() == Qt.Key_Delete:
         self.delete_selected_elements()
         self.repaint()