Python PyQt5.QtWidgets.QShortcut() Examples

The following are 30 code examples for showing how to use PyQt5.QtWidgets.QShortcut(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .

Example 1
Project: IDASkins   Author: zyantific   File: objectinspector.py    License: MIT License 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(ObjectInspector, self).__init__(*args, **kwargs)

        self._selected_widget = None
        self._ui = Ui_ObjectInspector()
        self._ui.setupUi(self)

        # Make everything monospace.
        font = QFont('Monospace')
        font.setStyleHint(QFont.TypeWriter)
        self._ui.teInspectionResults.setFont(font)

        # Register signals.
        self._update_key = QShortcut(QKeySequence(Qt.Key_F7), self)
        self._ui.btnSelectParent.released.connect(self.select_parent)
        self._update_key.activated.connect(self.update_inspection) 
Example 2
Project: parsec-cloud   Author: Scille   File: main_window.py    License: GNU Affero General Public License v3.0 6 votes vote down vote up
def _define_shortcuts(self):
        self.shortcut_close = QShortcut(QKeySequence(QKeySequence.Close), self)
        self.shortcut_close.activated.connect(self._shortcut_proxy(self.close_current_tab))
        self.shortcut_new_tab = QShortcut(QKeySequence(QKeySequence.AddTab), self)
        self.shortcut_new_tab.activated.connect(self._shortcut_proxy(self._on_add_instance_clicked))
        self.shortcut_settings = QShortcut(QKeySequence(_("Ctrl+K")), self)
        self.shortcut_settings.activated.connect(self._shortcut_proxy(self._show_settings))
        self.shortcut_menu = QShortcut(QKeySequence(_("Alt+E")), self)
        self.shortcut_menu.activated.connect(self._shortcut_proxy(self._show_menu))
        self.shortcut_help = QShortcut(QKeySequence(QKeySequence.HelpContents), self)
        self.shortcut_help.activated.connect(self._shortcut_proxy(self._on_show_doc_clicked))
        self.shortcut_quit = QShortcut(QKeySequence(QKeySequence.Quit), self)
        self.shortcut_quit.activated.connect(self._shortcut_proxy(self.close_app))
        self.shortcut_create_org = QShortcut(QKeySequence(QKeySequence.New), self)
        self.shortcut_create_org.activated.connect(
            self._shortcut_proxy(self._on_create_org_clicked)
        )
        self.shortcut_join_org = QShortcut(QKeySequence(QKeySequence.Open), self)
        self.shortcut_join_org.activated.connect(self._shortcut_proxy(self._on_join_org_clicked))
        shortcut = QShortcut(QKeySequence(QKeySequence.NextChild), self)
        shortcut.activated.connect(self._shortcut_proxy(self._cycle_tabs(1)))
        shortcut = QShortcut(QKeySequence(QKeySequence.PreviousChild), self)
        shortcut.activated.connect(self._shortcut_proxy(self._cycle_tabs(-1))) 
Example 3
Project: spinalcordtoolbox   Author: neuropoly   File: base.py    License: MIT License 6 votes vote down vote up
def _init_ui(self):
        self.resize(1200, 800)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        layout = QtWidgets.QVBoxLayout(self)

        self._init_header(layout)
        self._init_canvas(layout)
        self._init_controls(layout)
        self._init_footer(layout)

        events = (
            (QtGui.QKeySequence.Undo, self.on_undo),
            (QtGui.QKeySequence.Save, self.on_save_quit),
            (QtGui.QKeySequence.Quit, self.close),
            (QtGui.QKeySequence.MoveToNextChar, self.increment_vertical_nav),
            (QtGui.QKeySequence.MoveToPreviousChar, self.decrement_vertical_nav),
            (QtGui.QKeySequence.MoveToNextLine, self.increment_horizontal_nav),
            (QtGui.QKeySequence.MoveToPreviousLine, self.decrement_horizontal_nav)
        )

        for event, action in events:
            QtWidgets.QShortcut(event, self, action)

        self.setWindowTitle(self.params.dialog_title) 
Example 4
Project: code-jam-5   Author: python-discord   File: gui.py    License: MIT License 6 votes vote down vote up
def set_shortcuts(self):
        year_move_right = QtWidgets.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_Right), self)

        year_move_right.activated.connect(lambda: self.move_slider(self.year_step))

        year_move_left = QtWidgets.QShortcut(
            QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_Left), self)

        year_move_left.activated.connect(lambda: self.move_slider(-self.year_step))

        month_move_right = QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Right), self)
        month_move_right.activated.connect(lambda: self.move_slider(1))

        month_move_left = QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Left), self)
        month_move_left.activated.connect(lambda: self.move_slider(-1)) 
Example 5
Project: Python-Application   Author: xflywind   File: Area.py    License: GNU General Public License v3.0 6 votes vote down vote up
def init_action(self):
        zoom_minus = QShortcut(QKeySequence("Ctrl+-"), self)
        zoom_minus.activated.connect(self.minus)       
        zoom_plus = QShortcut(QKeySequence("Ctrl+="), self)
        zoom_plus.activated.connect(self.plus) 
        
        switch_left = QShortcut(QKeySequence(Qt.Key_Left), self)
        switch_left.activated.connect(self.left)       
        switch_right = QShortcut(QKeySequence(Qt.Key_Right), self)
        switch_right.activated.connect(self.right) 
        
        
        '''
        a1 = QAction(self)
        a1.setShortcut('Ctrl++')
        self.addAction(a1)
        a1.triggered.connect(self.plus)
        
        a2 = QAction(self)
        a2.setShortcut('Ctrl+-')
        self.addAction(a2)
        a2.triggered.connect(self.minus)
        ''' 
Example 6
Project: dcc   Author: amimo   File: HexViewMode.py    License: Apache License 2.0 5 votes vote down vote up
def initUI(self):
        self.setWindowTitle('Annotations')
        self.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)

        shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Shift+/"), self, self.close, self.close) 
Example 7
Project: dcc   Author: amimo   File: binwindow.py    License: Apache License 2.0 5 votes vote down vote up
def initUI(self):

        self.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)

        shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("/"), self, self.close, self.close)

        self.ui.pushButton.clicked.connect(self.onClicked)

        width = self.ui.size().width() + 15
        height = self.ui.size().height() + 15
        self.setFixedSize(width, height) 
Example 8
Project: Lector   Author: BasioMeusPuga   File: widgets.py    License: GNU General Public License v3.0 5 votes vote down vote up
def generate_keyboard_shortcuts(self):
        ksNextChapter = QtWidgets.QShortcut(
            QtGui.QKeySequence('Right'), self.contentView)
        ksNextChapter.setObjectName('nextChapter')
        ksNextChapter.activated.connect(self.sneaky_change)

        ksPrevChapter = QtWidgets.QShortcut(
            QtGui.QKeySequence('Left'), self.contentView)
        ksPrevChapter.setObjectName('prevChapter')
        ksPrevChapter.activated.connect(self.sneaky_change)

        ksGoFullscreen = QtWidgets.QShortcut(
            QtGui.QKeySequence('F'), self.contentView)
        ksGoFullscreen.activated.connect(self.go_fullscreen)

        ksExitFullscreen = QtWidgets.QShortcut(
            QtGui.QKeySequence('Escape'), self.contentView)
        ksExitFullscreen.setContext(QtCore.Qt.ApplicationShortcut)
        ksExitFullscreen.activated.connect(self.exit_fullscreen)

        ksToggleBookmarks = QtWidgets.QShortcut(
            QtGui.QKeySequence('Ctrl+B'), self.contentView)
        ksToggleBookmarks.activated.connect(
            lambda: self.toggle_side_dock(0))

        # Shortcuts not required for comic view functionality
        if not self.are_we_doing_images_only:
            ksToggleAnnotations = QtWidgets.QShortcut(
                QtGui.QKeySequence('Ctrl+N'), self.contentView)
            ksToggleAnnotations.activated.connect(
                lambda: self.toggle_side_dock(1))

            ksToggleSearch = QtWidgets.QShortcut(
                QtGui.QKeySequence('Ctrl+F'), self.contentView)
            ksToggleSearch.activated.connect(
                lambda: self.toggle_side_dock(2)) 
Example 9
Project: qiew   Author: mtivadar   File: qiew.py    License: GNU General Public License v2.0 5 votes vote down vote up
def initUI(self):      

        self.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)

        shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("F4"), self, self.close, self.close)
        #QtCore.QObject.connect(self.ui.ok, QtCore.SIGNAL('clicked()'), self.onClicked) 
Example 10
Project: qiew   Author: mtivadar   File: qiew.py    License: GNU General Public License v2.0 5 votes vote down vote up
def initUI(self):      

        self.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)

        shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("F10"), self, self.close, self.close)

        self.ui.rsel.setChecked(True)
        self.ui.rbin.setChecked(True)
        #QtCore.QObject.connect(self.ui.ok, QtCore.SIGNAL('clicked()'), self.onClicked)
        self.ui.ok.clicked.connect(lambda: self.onClicked()) 
Example 11
Project: qiew   Author: mtivadar   File: qiew.py    License: GNU General Public License v2.0 5 votes vote down vote up
def initUI(self):

        self.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)

        shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("/"), self, self.close, self.close)

        self.ui.pushButton.clicked.connect(lambda x: self.onClicked())

        width = self.ui.size().width()+15
        height = self.ui.size().height()+15
        self.setFixedSize(width, height) 
Example 12
Project: qiew   Author: mtivadar   File: FileFormat.py    License: GNU General Public License v2.0 5 votes vote down vote up
def initUI(self):      

        self.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)

        shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Alt+G"), self, self.close, self.close)

        self.ui.setWindowTitle('GoTo')

        self.ui.lineEdit.returnPressed.connect(lambda: self.onReturnPressed()) 
Example 13
Project: qiew   Author: mtivadar   File: HexViewMode.py    License: GNU General Public License v2.0 5 votes vote down vote up
def initUI(self):

        self.setWindowTitle('Annotations')
        self.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)

        shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Shift+/"), self, self.close, self.close) 
Example 14
Project: qiew   Author: mtivadar   File: bootsector.py    License: GNU General Public License v2.0 5 votes vote down vote up
def registerShortcuts(self, parent):
        self._parent = parent
        self.w = WHeaders(parent, self)
        self._writeData(self.w)
        shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Alt+P"), parent, self._showit, self._showit)

        self.g = MyDialogGoto(parent, self)
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("Alt+G"), parent, self._g_showit, self._g_showit)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("F3"), parent, self.F3, self.F3)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("["), parent, self.skip_section_dw, self.skip_section_dw)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("]"), parent, self.skip_section_up, self.skip_section_up)] 
Example 15
Project: qiew   Author: mtivadar   File: bootsector.py    License: GNU General Public License v2.0 5 votes vote down vote up
def initUI(self):      

        self.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)

        shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Alt+P"), self, self.close, self.close) 
Example 16
Project: qiew   Author: mtivadar   File: apk.py    License: GNU General Public License v2.0 5 votes vote down vote up
def registerShortcuts(self, parent):
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("Alt+P"), parent, self.showPermissions, self.showPermissions)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("Alt+E"), parent, self.showEntrypoints, self.showEntrypoints)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("Alt+F"), parent, self.showFiles, self.showFiles)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("Alt+G"), parent, self._g_showit, self._g_showit)]
        
        return 
Example 17
Project: qiew   Author: mtivadar   File: apk.py    License: GNU General Public License v2.0 5 votes vote down vote up
def initUI(self):      

        self.setWindowTitle('APK plugin')
        self.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)

        shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Alt+F"), self, self.close, self.close) 
Example 18
Project: qiew   Author: mtivadar   File: binary.py    License: GNU General Public License v2.0 5 votes vote down vote up
def registerShortcuts(self, parent):
        self._parent = parent
        self.w = DialogGoto(parent, self)
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("Alt+G"), parent, self._showit, self._showit)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("s"), parent, self.skip_chars, self.skip_chars)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("e"), parent, self.skip_block, self.skip_block)] 
Example 19
Project: qiew   Author: mtivadar   File: pe.py    License: GNU General Public License v2.0 5 votes vote down vote up
def registerShortcuts(self, parent):
        self.w = WHeaders(parent, self)
        self._parent = parent

        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("Alt+H"), parent, self.doit, self.doit)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("Alt+V"), parent, self.shortVersionInfo, self.shortVersionInfo)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("Alt+H"), parent, self.shortHeader, self.shortHeader)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("Alt+I"), parent, self.shortImports, self.shortImports)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("Alt+E"), parent, self.shortExports, self.shortExports)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("Alt+S"), parent, self.shortSections, self.shortSections)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("Alt+D"), parent, self.shortDirectories, self.shortDirectories)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("F7"), parent, self.F7, self.F7)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("F3"), parent, self.F3, self.F3)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("s"), parent, self.skip_chars, self.skip_chars)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("e"), parent, self.skip_block, self.skip_block)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("["), parent, self.skip_section_dw, self.skip_section_dw)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("]"), parent, self.skip_section_up, self.skip_section_up)]
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("0"), parent, self.jump_overlay, self.jump_overlay)]

        self.writeData(self.w)

        self.dgoto = PEDialogGoto(parent, self)
        self._Shortcuts += [QtWidgets.QShortcut(QtGui.QKeySequence("Alt+G"), parent, self._showGoto, self._showGoto)]


# GoTo dialog (inheritance from FileFormat DialogGoto) 
Example 20
Project: qiew   Author: mtivadar   File: pe.py    License: GNU General Public License v2.0 5 votes vote down vote up
def initUI(self):      

        self.setWindowTitle('PE plugin')
        self.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)

        shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Alt+F"), self, self.close, self.close) 
Example 21
Project: nanovna-saver   Author: NanoVNA-Saver   File: Bands.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, app: QtWidgets.QWidget):
        super().__init__()

        self.app = app
        self.setWindowTitle("Manage bands")
        self.setWindowIcon(self.app.icon)

        QtWidgets.QShortcut(QtCore.Qt.Key_Escape, self, self.hide)

        layout = QtWidgets.QVBoxLayout()
        self.setLayout(layout)
        self.setMinimumSize(500, 300)

        self.bands_table = QtWidgets.QTableView()
        self.bands_table.setModel(self.app.bands)
        self.bands_table.horizontalHeader().setStretchLastSection(True)

        layout.addWidget(self.bands_table)

        btn_add_row = QtWidgets.QPushButton("Add row")
        btn_delete_row = QtWidgets.QPushButton("Delete row")
        btn_reset_bands = QtWidgets.QPushButton("Reset bands")
        btn_layout = QtWidgets.QHBoxLayout()
        btn_layout.addWidget(btn_add_row)
        btn_layout.addWidget(btn_delete_row)
        btn_layout.addWidget(btn_reset_bands)
        layout.addLayout(btn_layout)

        btn_add_row.clicked.connect(self.app.bands.addRow)
        btn_delete_row.clicked.connect(self.deleteRows)
        btn_reset_bands.clicked.connect(self.resetBands) 
Example 22
Project: nanovna-saver   Author: NanoVNA-Saver   File: Screenshot.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        super().__init__()
        self.setWindowTitle("Screenshot")
        # TODO : self.setWindowIcon(self.app.icon)

        QtWidgets.QShortcut(QtCore.Qt.Key_Escape, self, self.hide)
        self.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)

        self.action_original_size = QtWidgets.QAction("Original size")
        self.action_original_size.triggered.connect(lambda: self.setScale(1))
        self.action_2x_size = QtWidgets.QAction("2x size")
        self.action_2x_size.triggered.connect(lambda: self.setScale(2))
        self.action_3x_size = QtWidgets.QAction("3x size")
        self.action_3x_size.triggered.connect(lambda: self.setScale(3))
        self.action_4x_size = QtWidgets.QAction("4x size")
        self.action_4x_size.triggered.connect(lambda: self.setScale(4))
        self.action_5x_size = QtWidgets.QAction("5x size")
        self.action_5x_size.triggered.connect(lambda: self.setScale(5))

        self.addAction(self.action_original_size)
        self.addAction(self.action_2x_size)
        self.addAction(self.action_3x_size)
        self.addAction(self.action_4x_size)
        self.addAction(self.action_5x_size)
        self.action_save_screenshot = QtWidgets.QAction("Save image")
        self.action_save_screenshot.triggered.connect(self.saveScreenshot)
        self.addAction(self.action_save_screenshot) 
Example 23
Project: FeelUOwn   Author: feeluown   File: hotkey.py    License: GNU General Public License v3.0 5 votes vote down vote up
def register(self, key_sequences, callback):
        if isinstance(key_sequences, list):
            key_sequences = key_sequences
        else:
            key_sequences = [key_sequences]

        for key_sequence in key_sequences:
            shortcut = QShortcut(key_sequence, self._app)
            shortcut.activated.connect(callback) 
Example 24
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1116.py    License: MIT License 5 votes vote down vote up
def qui_key(self, key_name, key_combo, func):
        self.hotkey[key_name] = QtWidgets.QShortcut(QtGui.QKeySequence(key_combo), self)
        self.hotkey[key_name].activated.connect( func ) 
Example 25
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1116.py    License: MIT License 5 votes vote down vote up
def Establish_Connections(self):
        super(self.__class__,self).Establish_Connections()
        # custom ui response
        # shortcut connection
        self.hotkey = {}
        # self.hotkey['my_key'] = QtWidgets.QShortcut(QtGui.QKeySequence( "Ctrl+1" ), self)
        # self.hotkey['my_key'].activated.connect(self.my_key_func)
    # ---- user response list ---- 
Example 26
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1020.py    License: MIT License 5 votes vote down vote up
def qui_key(self, key_name, key_combo, func):
        self.hotkey[key_name] = QtWidgets.QShortcut(QtGui.QKeySequence(key_combo), self)
        self.hotkey[key_name].activated.connect( func ) 
Example 27
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1020.py    License: MIT License 5 votes vote down vote up
def Establish_Connections(self):
        super(self.__class__,self).Establish_Connections()
        # custom ui response
        # shortcut connection
        self.hotkey = {}
        # self.hotkey['my_key'] = QtWidgets.QShortcut(QtGui.QKeySequence( "Ctrl+1" ), self)
        # self.hotkey['my_key'].activated.connect(self.my_key_func)
    # ---- user response list ---- 
Example 28
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_2010.py    License: MIT License 5 votes vote down vote up
def qui_key(self, key_name, key_combo, func):
        self.hotkey[key_name] = QtWidgets.QShortcut(QtGui.QKeySequence(key_combo), self)
        self.hotkey[key_name].activated.connect( func ) 
Example 29
Project: universal_tool_template.py   Author: shiningdesign   File: GearBox_template_1010.py    License: MIT License 5 votes vote down vote up
def Establish_Connections(self):
        super(self.__class__,self).Establish_Connections()
        # custom ui response
        # shortcut connection
        self.hotkey = {}
        # self.hotkey['my_key'] = QtWidgets.QShortcut(QtGui.QKeySequence( "Ctrl+1" ), self)
        # self.hotkey['my_key'].activated.connect(self.my_key_func)
    # ---- user response list ---- 
Example 30
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1115.py    License: MIT License 5 votes vote down vote up
def qui_key(self, key_name, key_combo, func):
        self.hotkey[key_name] = QtWidgets.QShortcut(QtGui.QKeySequence(key_combo), self)
        self.hotkey[key_name].activated.connect( func )