我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用PyQt5.QtCore.Qt.SHIFT。
def __init__(self): self.version = 100 # Assume oldest config self.root_dir = QDir().currentPath() self.send_sleep = 0.1 self.read_sleep = 0.1 self.use_transfer_scripts = True self.external_transfer_scripts_folder = None self.wifi_presets = [] self.python_flash_executable = None self.last_firmware_directory = None self.debug_mode = False self._geometries = {} self.external_editor_path = None self.external_editor_args = None self.new_line_key = QKeySequence(Qt.SHIFT + Qt.Key_Return, Qt.SHIFT + Qt.Key_Enter) self.send_key = QKeySequence(Qt.Key_Return, Qt.Key_Enter) self.terminal_tab_spaces = 4 self.mpy_cross_path = None self.preferred_port = None self.auto_transfer = False if not self.load(): if not self.load_old(): # No config found, init at newest version self.version = Settings.newest_version return self._update_config()
def key_event_sequence(event): val = event.key() mod = event.modifiers() if mod & Qt.ShiftModifier: val += Qt.SHIFT if mod & Qt.ControlModifier: val += Qt.CTRL if mod & Qt.AltModifier: val += Qt.ALT if mod & Qt.MetaModifier: val += Qt.META return QKeySequence(val)
def translateModifiers(self, state, text): result = 0 if ((state & Qt.ShiftModifier) and (len(text) == 0 or not text[0].isprintable() or text[0].isalpha() or text[0].isspace())): result |= Qt.SHIFT if (state & Qt.ControlModifier): result |= Qt.CTRL if (state & Qt.MetaModifier): result |= Qt.META if (state & Qt.AltModifier): result |= Qt.ALT return result