Python PyQt5.QtGui.QKeySequence() Examples

The following are code examples for showing how to use PyQt5.QtGui.QKeySequence(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: core_messenger   Author: arterialist   File: message_input.py    GNU General Public License v3.0 6 votes vote down vote up
def init_ui(self):
        layout = QHBoxLayout()

        self.message_input.setStyleSheet(ThemeLoader.loaded_theme.get_default_for_widget(self.message_input))
        self.message_input.setAutoFormatting(QTextEdit.AutoAll)

        self.send_button.clicked.connect(lambda: self.send_button_clicked())
        shortcut = QShortcut(QKeySequence("Ctrl+Return"), self.send_button)
        shortcut.activated.connect(lambda: self.send_button_clicked(True))
        shortcut.setEnabled(True)
        self.send_button.clicked.connect(lambda: self.send_button_clicked(True))
        self.send_button.setStyleSheet(ThemeLoader.loaded_theme.apply_to_stylesheet(button_style))

        layout.addWidget(self.message_input)
        layout.addWidget(self.send_button)
        layout.setContentsMargins(0, 0, 0, 0)

        self.setLayout(layout) 
Example 2
Project: PocketBrowser   Author: chenzd123456   File: View.py    MIT License 6 votes vote down vote up
def __init__(self, parent=None, flags=Qt.WindowFlags()):
        super().__init__(parent=parent, flags=flags)

        tab_web_widget = TabWebWidget(self)
        status_bar = StatusBar()

        self.setCentralWidget(tab_web_widget)
        self.setStatusBar(status_bar)

        #### 快捷键 ####
        # 按F11全屏
        fullscreen_shortcut = QShortcut(QKeySequence("F11"), self)
        fullscreen_shortcut.activated.connect(self._swithFullScreen)
        # 按ESC进入命令模式
        cmd_mode_shortcut = QShortcut(QKeySequence("ESCAPE"), self)
        cmd_mode_shortcut.activated.connect(
            lambda: self.statusBar().setCmdMode(True)) 
Example 3
Project: PointlessMaker   Author: aboood40091   File: main.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self):
        super().__init__(None)
        self.setWindowTitle('PointlessMaker v0.2')
        self.setUnifiedTitleAndToolBarOnMac(True)

        self.UpdateFlag = False
        self.selObj = None
        self.CurrentSelection = []

        self.scene = Scene(0, -(27 * globals.TileWidth), 241 * globals.TileWidth, 28 * globals.TileWidth, self)
        self.scene.setItemIndexMethod(QtWidgets.QGraphicsScene.NoIndex)
        self.scene.selectionChanged.connect(self.handleSceneSelectionChanged)

        self.graphicsView = LevelViewWidget(self.scene, self)
        self.graphicsView.centerOn(0, -(26.5 * globals.TileWidth))

        self.setCentralWidget(self.graphicsView)

        self.selAllShort = QtWidgets.QShortcut(QtGui.QKeySequence.SelectAll, self)
        self.selAllShort.activated.connect(self.SelectAll)

        self.gridShort = QtWidgets.QShortcut(QtGui.QKeySequence('G'), self)
        self.gridShort.activated.connect(self.ToggleGrid) 
Example 4
Project: PointlessMaker   Author: aboood40091   File: main.py    GNU General Public License v3.0 6 votes vote down vote up
def createMenubar(self):
        self.CreateAction('openfromfile', self.HandleOpenFromFile, None,
                          'Open Level by File...', 'Open a level based on its filename',
                          QtGui.QKeySequence('Ctrl+Shift+O'))
        self.CreateAction('save', self.HandleSaveAs, None, 'Save Level',
                          'Save the level back to the archive file', QtGui.QKeySequence.Save)
        self.CreateAction('screenshot', self.HandleScreenshot, None, 'Level Screenshot...',
                          'Take a full size screenshot of your level for you to share', QtGui.QKeySequence('Ctrl+Alt+S'))


        menubar = QtWidgets.QMenuBar()
        self.setMenuBar(menubar)

        fmenu = menubar.addMenu('&File')
        fmenu.addAction(self.actions['openfromfile'])
        fmenu.addSeparator()
        fmenu.addAction(self.actions['save'])
        fmenu.addSeparator()
        fmenu.addAction(self.actions['screenshot']) 
Example 5
Project: QMusic   Author: dragondjf   File: dmenu.py    GNU Lesser General Public License v2.1 6 votes vote down vote up
def creatAction(self, submenu, menuaction):
        if 'checkable' in menuaction:
            setattr(self,
                    '%sAction' % menuaction['trigger'],
                    QAction(
                        QIcon(QPixmap(menuaction['icon'])),
                        u'%s' % menuaction['name'],
                        self,
                        checkable=menuaction['checkable']))
        else:
            setattr(self, '%sAction' % menuaction['trigger'], QAction(
                QIcon(QPixmap(menuaction['icon'])),
                u'%s' % menuaction['name'],
                self, ))

        action = getattr(self, '%sAction' % menuaction['trigger'])
        action.setShortcut(QKeySequence(menuaction['shortcut']))
        submenu.addAction(action)
        self.qactions.update({menuaction['trigger']: action}) 
Example 6
Project: poitagger   Author: dlr-eoc   File: treeview.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self,parent = None):
        super(TreeWidget, self).__init__(parent)
        uic.loadUi(os.path.join(PATHS["UI"],'treemain.ui'),self)
        self.setWindowFlags(QtCore.Qt.Widget)
        self.view = TreeView()
        self.vb = ViewButtons()
        self.setCentralWidget(self.view)
        self.statusbar.addWidget(self.vb)
        
        
        #self.rightAction = QAction('right', self)
        #self.leftAction = QAction('left', self)
        #self.createKeyCtrl(self.rightAction, QtCore.Qt.Key_Right)
        #self.createKeyCtrl(self.leftAction, QtCore.Qt.Key_Left)
        self.connections()
    
    #def createKeyCtrl(self,actionName, key):
    #    actionName.setShortcut(QtGui.QKeySequence(key))
    #    self.addAction(actionName) 
Example 7
Project: SyntaxAutoFix   Author: Mte90   File: manageterms-gui.py    GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent=None):
        # Load the ui
        QMainWindow.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        # Connect the function with the signal
        self.ui.save.clicked.connect(self.store_new_argument)
        self.ui.save.clicked.connect(self.save_and_clear)
        self.ui.save_close.clicked.connect(self.save_close)
        # When the software are closed on console the software are closed
        signal.signal(signal.SIGINT, signal.SIG_DFL)
        self.script_path = os.path.dirname(os.path.realpath(__file__)) + '/words/'
        for filepath in sorted(glob.glob(os.path.join(self.script_path, '*.json'))):
            language = os.path.splitext(os.path.basename(filepath))[0]
            self.ui.languages.addItem(language)
        enter = QShortcut(QKeySequence(QtCore.Qt.Key_Return), self)
        enter.activated.connect(self.save_close)
        self.show() 
Example 8
Project: StarCraft-Casting-Tool   Author: teampheenix   File: subConnections.py    GNU General Public License v3.0 6 votes vote down vote up
def createButtonGroup(self):
        """Create buttons."""
        try:
            layout = QHBoxLayout()

            layout.addWidget(QLabel(""))

            buttonCancel = QPushButton(_('Cancel'))
            buttonCancel.clicked.connect(self.closeWindow)
            layout.addWidget(buttonCancel)

            buttonSave = QPushButton(_('&Save && Close'))
            buttonSave.setToolTip(_("Shortcut: {}").format("Ctrl+S"))
            self.shortcut = QShortcut(QKeySequence("Ctrl+S"), self)
            self.shortcut.setAutoRepeat(False)
            self.shortcut.activated.connect(self.saveCloseWindow)
            buttonSave.clicked.connect(self.saveCloseWindow)
            layout.addWidget(buttonSave)

            self.buttonGroup = layout
        except Exception:
            module_logger.exception("message") 
Example 9
Project: StarCraft-Casting-Tool   Author: teampheenix   File: subMisc.py    GNU General Public License v3.0 6 votes vote down vote up
def createButtonGroup(self):
        """Create buttons."""
        try:
            layout = QHBoxLayout()

            layout.addWidget(QLabel(""))

            buttonCancel = QPushButton(_('Cancel'))
            buttonCancel.clicked.connect(self.closeWindow)
            layout.addWidget(buttonCancel)

            buttonSave = QPushButton(_('&Save && Close'))
            buttonSave.setToolTip(_("Shortcut: {}").format("Ctrl+S"))
            self.shortcut = QShortcut(QKeySequence("Ctrl+S"), self)
            self.shortcut.setAutoRepeat(False)
            self.shortcut.activated.connect(self.saveCloseWindow)
            buttonSave.clicked.connect(self.saveCloseWindow)
            layout.addWidget(buttonSave)

            self.buttonGroup = layout
        except Exception:
            module_logger.exception("message") 
Example 10
Project: StarCraft-Casting-Tool   Author: teampheenix   File: subStyles.py    GNU General Public License v3.0 6 votes vote down vote up
def createButtonGroup(self):
        """Create buttons."""
        try:
            layout = QHBoxLayout()

            layout.addWidget(QLabel(""))

            buttonCancel = QPushButton(_('Cancel'))
            buttonCancel.clicked.connect(self.closeWindow)
            layout.addWidget(buttonCancel)

            buttonSave = QPushButton(_('&Save && Close'))
            buttonSave.setToolTip(_("Shortcut: {}").format("Ctrl+S"))
            self.shortcut = QShortcut(QKeySequence("Ctrl+S"), self)
            self.shortcut.setAutoRepeat(False)
            self.shortcut.activated.connect(self.saveCloseWindow)
            buttonSave.clicked.connect(self.saveCloseWindow)
            layout.addWidget(buttonSave)

            self.buttonGroup = layout
        except Exception:
            module_logger.exception("message") 
Example 11
Project: StarCraft-Casting-Tool   Author: teampheenix   File: subBrowserSources.py    GNU General Public License v3.0 6 votes vote down vote up
def createButtonGroup(self):
        """Create buttons."""
        try:
            layout = QHBoxLayout()

            layout.addWidget(QLabel(""))

            buttonCancel = QPushButton(_('Cancel'))
            buttonCancel.clicked.connect(self.closeWindow)
            layout.addWidget(buttonCancel)

            buttonSave = QPushButton(_('&Save && Close'))
            buttonSave.setToolTip(_("Shortcut: {}").format("Ctrl+S"))
            self.shortcut = QShortcut(QKeySequence("Ctrl+S"), self)
            self.shortcut.setAutoRepeat(False)
            self.shortcut.activated.connect(self.saveCloseWindow)
            buttonSave.clicked.connect(self.saveCloseWindow)
            layout.addWidget(buttonSave)

            self.buttonGroup = layout
        except Exception:
            module_logger.exception("message") 
Example 12
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1116.py    MIT License 6 votes vote down vote up
def qui_menu(self, action_list_str, menu_str):
        # qui menu creation
        # syntax: self.qui_menu('right_menu_createFolder_atn;Create Folder,Ctrl+D | right_menu_openFolder_atn;Open Folder', 'right_menu')
        if menu_str not in self.uiList.keys():
            self.uiList[menu_str] = QtWidgets.QMenu()
        create_opt_list = [ x.strip() for x in action_list_str.split('|') ]
        for each_creation in create_opt_list:
            ui_info = [ x.strip() for x in each_creation.split(';') ]
            atn_name = ui_info[0]
            atn_title = ''
            atn_hotkey = ''
            if len(ui_info) > 1:
                options = ui_info[1].split(',')
                atn_title = '' if len(options) < 1 else options[0]
                atn_hotkey = '' if len(options) < 2 else options[1]
            if atn_name != '':
                if atn_name == '_':
                    self.uiList[menu_str].addSeparator()
                else:
                    if atn_name not in self.uiList.keys():
                        self.uiList[atn_name] = QtWidgets.QAction(atn_title, self)
                        if atn_hotkey != '':
                            self.uiList[atn_name].setShortcut(QtGui.QKeySequence(atn_hotkey))
                    self.uiList[menu_str].addAction(self.uiList[atn_name]) 
Example 13
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1020.py    MIT License 6 votes vote down vote up
def qui_menu(self, action_list_str, menu_str):
        # qui menu creation
        # syntax: self.qui_menu('right_menu_createFolder_atn;Create Folder,Ctrl+D | right_menu_openFolder_atn;Open Folder', 'right_menu')
        if menu_str not in self.uiList.keys():
            self.uiList[menu_str] = QtWidgets.QMenu()
        create_opt_list = [ x.strip() for x in action_list_str.split('|') ]
        for each_creation in create_opt_list:
            ui_info = [ x.strip() for x in each_creation.split(';') ]
            atn_name = ui_info[0]
            atn_title = ''
            atn_hotkey = ''
            if len(ui_info) > 1:
                options = ui_info[1].split(',')
                atn_title = '' if len(options) < 1 else options[0]
                atn_hotkey = '' if len(options) < 2 else options[1]
            if atn_name != '':
                if atn_name == '_':
                    self.uiList[menu_str].addSeparator()
                else:
                    if atn_name not in self.uiList.keys():
                        self.uiList[atn_name] = QtWidgets.QAction(atn_title, self)
                        if atn_hotkey != '':
                            self.uiList[atn_name].setShortcut(QtGui.QKeySequence(atn_hotkey))
                    self.uiList[menu_str].addAction(self.uiList[atn_name]) 
Example 14
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_2010.py    MIT License 6 votes vote down vote up
def qui_menu(self, action_list_str, menu_str):
        # qui menu creation
        # syntax: self.qui_menu('right_menu_createFolder_atn;Create Folder,Ctrl+D | right_menu_openFolder_atn;Open Folder', 'right_menu')
        if menu_str not in self.uiList.keys():
            self.uiList[menu_str] = QtWidgets.QMenu()
        create_opt_list = [ x.strip() for x in action_list_str.split('|') ]
        for each_creation in create_opt_list:
            ui_info = [ x.strip() for x in each_creation.split(';') ]
            atn_name = ui_info[0]
            atn_title = ''
            atn_hotkey = ''
            if len(ui_info) > 1:
                options = ui_info[1].split(',')
                atn_title = '' if len(options) < 1 else options[0]
                atn_hotkey = '' if len(options) < 2 else options[1]
            if atn_name != '':
                if atn_name == '_':
                    self.uiList[menu_str].addSeparator()
                else:
                    if atn_name not in self.uiList.keys():
                        self.uiList[atn_name] = QtWidgets.QAction(atn_title, self)
                        if atn_hotkey != '':
                            self.uiList[atn_name].setShortcut(QtGui.QKeySequence(atn_hotkey))
                    self.uiList[menu_str].addAction(self.uiList[atn_name]) 
Example 15
Project: universal_tool_template.py   Author: shiningdesign   File: UITranslator.py    MIT License 6 votes vote down vote up
def setupMenu(self):
        self.quickMenu(['file_menu;&File','setting_menu;&Setting','help_menu;&Help'])
        cur_menu = self.uiList['setting_menu']
        self.quickMenuAction('setParaA_atn','Set Parameter &A','A example of tip notice.','setParaA.png', cur_menu)
        self.uiList['setParaA_atn'].setShortcut(QtGui.QKeySequence("Ctrl+R"))
        cur_menu.addSeparator()
        # for file menu
        cur_menu = self.uiList['file_menu']
        self.quickMenuAction('newLang_atn','&Add New Language','Add a new translation.','newLang.png', cur_menu)
        self.quickMenuAction('resetLang_atn','&Reset Languages','Reset All.','resetLang.png', cur_menu)
        # for info review
        cur_menu = self.uiList['help_menu']
        self.quickMenuAction('helpHostMode_atnNone','Host Mode - {}'.format(hostMode),'Host Running.','', cur_menu)
        self.quickMenuAction('helpPyMode_atnNone','Python Mode - {}'.format(pyMode),'Python Library Running.','', cur_menu)
        self.quickMenuAction('helpQtMode_atnNone','Qt Mode - {}'.format(qtModeList[qtMode]),'Qt Library Running.','', cur_menu)
        self.quickMenuAction('helpTemplate_atnNone','Universal Tool Teamplate - {}'.format(tpl_ver),'based on Univeral Tool Template v{} by Shining Ying - https://github.com/shiningdesign/universal_tool_template.py'.format(tpl_ver),'', cur_menu)
        cur_menu.addSeparator()
        self.uiList['helpGuide_msg'] = "How to Use:\n1. Put source info in\n2. Click Process button\n3. Check result output\n4. Save memory info into a file."
        self.quickMenuAction('helpGuide_atnMsg','Usage Guide','How to Usge Guide.','helpGuide.png', cur_menu) 
Example 16
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1115.py    MIT License 6 votes vote down vote up
def qui_menu(self, action_list_str, menu_str):
        # qui menu creation
        # syntax: self.qui_menu('right_menu_createFolder_atn;Create Folder,Ctrl+D | right_menu_openFolder_atn;Open Folder', 'right_menu')
        if menu_str not in self.uiList.keys():
            self.uiList[menu_str] = QtWidgets.QMenu()
        create_opt_list = [ x.strip() for x in action_list_str.split('|') ]
        for each_creation in create_opt_list:
            ui_info = [ x.strip() for x in each_creation.split(';') ]
            atn_name = ui_info[0]
            atn_title = ''
            atn_hotkey = ''
            if len(ui_info) > 1:
                options = ui_info[1].split(',')
                atn_title = '' if len(options) < 1 else options[0]
                atn_hotkey = '' if len(options) < 2 else options[1]
            if atn_name != '':
                if atn_name == '_':
                    self.uiList[menu_str].addSeparator()
                else:
                    if atn_name not in self.uiList.keys():
                        self.uiList[atn_name] = QtWidgets.QAction(atn_title, self)
                        if atn_hotkey != '':
                            self.uiList[atn_name].setShortcut(QtGui.QKeySequence(atn_hotkey))
                    self.uiList[menu_str].addAction(self.uiList[atn_name]) 
Example 17
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1112.py    MIT License 6 votes vote down vote up
def qui_menu(self, action_list_str, menu_str):
        # qui menu creation
        # syntax: self.qui_menu('right_menu_createFolder_atn;Create Folder,Ctrl+D | right_menu_openFolder_atn;Open Folder', 'right_menu')
        if menu_str not in self.uiList.keys():
            self.uiList[menu_str] = QtWidgets.QMenu()
        create_opt_list = [ x.strip() for x in action_list_str.split('|') ]
        for each_creation in create_opt_list:
            ui_info = [ x.strip() for x in each_creation.split(';') ]
            atn_name = ui_info[0]
            atn_title = ''
            atn_hotkey = ''
            if len(ui_info) > 1:
                options = ui_info[1].split(',')
                atn_title = '' if len(options) < 1 else options[0]
                atn_hotkey = '' if len(options) < 2 else options[1]
            if atn_name != '':
                if atn_name == '_':
                    self.uiList[menu_str].addSeparator()
                else:
                    if atn_name not in self.uiList.keys():
                        self.uiList[atn_name] = QtWidgets.QAction(atn_title, self)
                        if atn_hotkey != '':
                            self.uiList[atn_name].setShortcut(QtGui.QKeySequence(atn_hotkey))
                    self.uiList[menu_str].addAction(self.uiList[atn_name]) 
Example 18
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1110.py    MIT License 6 votes vote down vote up
def qui_menu(self, action_list_str, menu_str):
        # qui menu creation
        # syntax: self.qui_menu('right_menu_createFolder_atn;Create Folder,Ctrl+D | right_menu_openFolder_atn;Open Folder', 'right_menu')
        if menu_str not in self.uiList.keys():
            self.uiList[menu_str] = QtWidgets.QMenu()
        create_opt_list = [ x.strip() for x in action_list_str.split('|') ]
        for each_creation in create_opt_list:
            ui_info = [ x.strip() for x in each_creation.split(';') ]
            atn_name = ui_info[0]
            atn_title = ''
            atn_hotkey = ''
            if len(ui_info) > 1:
                options = ui_info[1].split(',')
                atn_title = '' if len(options) < 1 else options[0]
                atn_hotkey = '' if len(options) < 2 else options[1]
            if atn_name != '':
                if atn_name == '_':
                    self.uiList[menu_str].addSeparator()
                else:
                    if atn_name not in self.uiList.keys():
                        self.uiList[atn_name] = QtWidgets.QAction(atn_title, self)
                        if atn_hotkey != '':
                            self.uiList[atn_name].setShortcut(QtGui.QKeySequence(atn_hotkey))
                    self.uiList[menu_str].addAction(self.uiList[atn_name]) 
Example 19
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_0803.py    MIT License 6 votes vote down vote up
def setupMenu(self):
        self.quickMenu(['file_menu;&File','setting_menu;&Setting','help_menu;&Help'])
        cur_menu = self.uiList['setting_menu']
        self.quickMenuAction('setParaA_atn','Set Parameter &A','A example of tip notice.','setParaA.png', cur_menu)
        self.uiList['setParaA_atn'].setShortcut(QtGui.QKeySequence("Ctrl+R"))
        cur_menu.addSeparator()
        if 'help_menu' in self.uiList.keys():
            # for info review
            cur_menu = self.uiList['help_menu']
            self.quickMenuAction('helpHostMode_atnNone','Host Mode - {}'.format(hostMode),'Host Running.','', cur_menu)
            self.quickMenuAction('helpPyMode_atnNone','Python Mode - {}'.format(pyMode),'Python Library Running.','', cur_menu)
            self.quickMenuAction('helpQtMode_atnNone','Qt Mode - {}'.format(qtModeList[qtMode]),'Qt Library Running.','', cur_menu)
            self.quickMenuAction('helpTemplate_atnNone','Universal Tool Teamplate - {}'.format(tpl_ver),'based on Univeral Tool Template v{0} by Shining Ying - https://github.com/shiningdesign/universal{1}tool{1}template.py'.format(tpl_ver,'_'),'', cur_menu)
            cur_menu.addSeparator()
            self.uiList['helpGuide_msg'] = self.help
            self.quickMenuAction('helpGuide_atnMsg','Usage Guide','How to Usge Guide.','helpGuide.png', cur_menu) 
Example 20
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1010.py    MIT License 6 votes vote down vote up
def qui_menu(self, action_list_str, menu_str):
        # qui menu creation
        # syntax: self.qui_menu('right_menu_createFolder_atn;Create Folder,Ctrl+D | right_menu_openFolder_atn;Open Folder', 'right_menu')
        if menu_str not in self.uiList.keys():
            self.uiList[menu_str] = QtWidgets.QMenu()
        create_opt_list = [ x.strip() for x in action_list_str.split('|') ]
        for each_creation in create_opt_list:
            ui_info = [ x.strip() for x in each_creation.split(';') ]
            atn_name = ui_info[0]
            atn_title = ''
            atn_hotkey = ''
            if len(ui_info) > 1:
                options = ui_info[1].split(',')
                atn_title = '' if len(options) < 1 else options[0]
                atn_hotkey = '' if len(options) < 2 else options[1]
            if atn_name != '':
                if atn_name not in self.uiList.keys():
                    self.uiList[atn_name] = QtWidgets.QAction(atn_title, self)
                    if atn_hotkey != '':
                        self.uiList[atn_name].setShortcut(QtGui.QKeySequence(atn_hotkey))
                self.uiList[menu_str].addAction(self.uiList[atn_name]) 
Example 21
Project: PyNoder   Author: johnroper100   File: graph_view_widget.py    GNU General Public License v3.0 6 votes vote down vote up
def setGraphView(self, graphView):
        self.graphView = graphView

        # Setup Layout
        layout = QtWidgets.QVBoxLayout(self)
        layout.addWidget(self.graphView)
        self.setLayout(layout)

        # Setup hotkeys for the following actions.
        deleteShortcut = QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Delete), self)
        deleteShortcut.activated.connect(self.graphView.deleteSelectedNodes)

        frameShortcut = QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_F), self)
        frameShortcut.activated.connect(self.graphView.frameSelectedNodes)

        frameShortcut = QtWidgets.QShortcut(QtGui.QKeySequence(QtCore.Qt.Key_A), self)
        frameShortcut.activated.connect(self.graphView.frameAllNodes) 
Example 22
Project: dcc   Author: amimo   File: HexViewMode.py    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 23
Project: dcc   Author: amimo   File: binwindow.py    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 24
Project: GreenLuma-Reborn-Manager   Author: ImaniiTy   File: logic.py    MIT License 5 votes vote down vote up
def setup(self):
        self.setWindowIcon(QIcon("icon.ico"))

        # Hidde Other Windows
        self.main_window.profile_create_window.setHidden(True)
        self.main_window.searching_frame.setHidden(True)
        self.main_window.set_steam_path_window.setHidden(True)
        self.main_window.closing_steam.setHidden(True)
        self.main_window.generic_popup.setHidden(True)
        self.main_window.settings_window.setHidden(True)
        #-------

        self.main_window.version_label.setText("v{0}".format(core.CURRENT_VERSION))
        self.main_window.no_hook_checkbox.setChecked(core.config.no_hook)
        self.main_window.compatibility_mode_checkbox.setChecked(core.config.compatibility_mode)
        self.populate_list(self.main_window.games_list, games)
        self.main_window.games_list.dropEvent = self.drop_event_handler
        self.populate_table(self.main_window.search_result)
        self.show_profile_names()
        self.show_profile_games(profile_manager.profiles[self.main_window.profile_selector.currentText()])
        self.setup_steam_path()
        self.setup_search_table()
        # self.main_window.main_panel.raise_()

        # Settings Window Setup
        self.main_window.update_checkbox.setChecked(core.config.check_update)

        # Shortcuts
        del_game = QShortcut(QKeySequence(Qt.Key_Delete), self.main_window.games_list)
        del_game.activated.connect(self.remove_selected) 
Example 25
Project: Lector   Author: BasioMeusPuga   File: widgets.py    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 26
Project: Anki-TouchScreen   Author: krassowski   File: __init__.py    GNU General Public License v3.0 5 votes vote down vote up
def ts_setup_menu():
    """
    Initialize menu. If there is an entity "View" in top level menu
    (shared with other plugins, like "Zoom" of R. Sieker) options of
    the addon will be placed there. In other case it creates that menu.
    """
    global ts_menu_switch

    try:
        mw.addon_view_menu
    except AttributeError:
        mw.addon_view_menu = QMenu(_(u"&View"), mw)
        mw.form.menubar.insertMenu(mw.form.menuTools.menuAction(),
                                    mw.addon_view_menu)

    mw.ts_menu = QMenu(_('&Touchscreen'), mw)

    mw.addon_view_menu.addMenu(mw.ts_menu)

    ts_menu_switch = QAction(_('&Enable touchscreen mode'), mw, checkable=True)
    ts_menu_color = QAction(_('Set &pen color'), mw)
    ts_menu_width = QAction(_('Set pen &width'), mw)
    ts_menu_opacity = QAction(_('Set pen &opacity'), mw)
    ts_menu_about = QAction(_('&About...'), mw)

    ts_toggle_seq = QKeySequence("Ctrl+r")
    ts_menu_switch.setShortcut(ts_toggle_seq)

    mw.ts_menu.addAction(ts_menu_switch)
    mw.ts_menu.addAction(ts_menu_color)
    mw.ts_menu.addAction(ts_menu_width)
    mw.ts_menu.addAction(ts_menu_opacity)
    mw.ts_menu.addSeparator()
    mw.ts_menu.addAction(ts_menu_about)

    ts_menu_switch.triggered.connect(ts_switch)
    ts_menu_color.triggered.connect(ts_change_color)
    ts_menu_width.triggered.connect(ts_change_width)
    ts_menu_opacity.triggered.connect(ts_change_opacity)
    ts_menu_about.triggered.connect(ts_about) 
Example 27
Project: persepolis   Author: persepolisdm   File: setting.py    GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 28
Project: uPyLoader   Author: BetaRavener   File: qt_helper.py    MIT License 5 votes vote down vote up
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) 
Example 29
Project: uPyLoader   Author: BetaRavener   File: settings.py    MIT License 5 votes vote down vote up
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.use_custom_transfer_scripts = False
        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() 
Example 30
Project: uPyLoader   Author: BetaRavener   File: settings.py    MIT License 5 votes vote down vote up
def serialize(self):
        serialized = {}
        for key, val in self.__dict__.items():
            if isinstance(val, QKeySequence):
                val = val.toString()

            serialized[key] = val

        return serialized 
Example 31
Project: uPyLoader   Author: BetaRavener   File: settings.py    MIT License 5 votes vote down vote up
def deserialize(self, serialized):
        deserialized = {}
        for key, val in serialized.items():
            if key == "new_line_key" or key == "send_key":
                val = QKeySequence(val)

            deserialized[key] = val

        return deserialized 
Example 32
Project: PocketBrowser   Author: chenzd123456   File: View.py    MIT License 5 votes vote down vote up
def __init__(self, top, parent=None):
        super().__init__(parent=parent)

        self._top = top

        # self.setMovable(True)
        # self.setTabsClosable(True)
        self.setElideMode(Qt.ElideRight)
        # self.tabBar().setExpanding(True)
        # 当只有一个标签的时候隐藏标签
        # self.setTabBarAutoHide(True)
        # 设置关闭标签后的行为 Qt.SelectLeftTab, Qt.SelectRightTab, Qt.SelectPreviousTab
        # self.tarBar().setSelectionBehaviorOnRemove(Qt.SelectPreviousTab)

        self.addOneTabFore()

        self.tabBarDoubleClicked.connect(self._delOneTab)
        self.tabCloseRequested.connect(self._delOneTab)

        #### 快捷键 ####
        # 按CTRL+N新建标签页
        new_tab_shortcut = QShortcut(QKeySequence("CTRL+N"), self)
        new_tab_shortcut.activated.connect(self.addOneTabFore)
        # 按F5刷新当前页
        reload_shortcut = QShortcut(QKeySequence("F5"), self)
        reload_shortcut.activated.connect(self._reloadCurrentTab)
        # 按CTRL+LEFT切换前一个标签页
        prev_tab_shortcut = QShortcut(QKeySequence("CTRL+LEFT"), self)
        prev_tab_shortcut.activated.connect(self._prev_tab)
        # 按CTRL+RIGHT切换后一个标签页
        prev_tab_shortcut = QShortcut(QKeySequence("CTRL+RIGHT"), self)
        prev_tab_shortcut.activated.connect(self._next_tab)
        # 按CTRL+B后退
        backward_shortcut = QShortcut(QKeySequence("CTRL+B"), self)
        backward_shortcut.activated.connect(self.currentWidget().back)
        # 按CTRL+F前进
        forward_shortcut = QShortcut(QKeySequence("CTRL+F"), self)
        forward_shortcut.activated.connect(self.currentWidget().forward) 
Example 33
Project: chinese-support-redux   Author: luoliyan   File: gui.py    GNU General Public License v3.0 5 votes vote down vote up
def add_menu_item(path, text, func, keys=None, checkable=False, checked=False):
    action = QAction(text, mw)

    if keys:
        action.setShortcut(QKeySequence(keys))

    if checkable:
        action.setCheckable(checkable)
        action.toggled.connect(func)
        if not hasattr(mw, 'action_groups'):
            mw.action_groups = {}
        if path not in mw.action_groups:
            mw.action_groups[path] = QActionGroup(None)
        mw.action_groups[path].addAction(action)
        action.setChecked(checked)
    else:
        action.triggered.connect(func)

    if path == 'File':
        mw.form.menuCol.addAction(action)
    elif path == 'Edit':
        mw.form.menuEdit.addAction(action)
    elif path == 'Tools':
        mw.form.menuTools.addAction(action)
    elif path == 'Help':
        mw.form.menuHelp.addAction(action)
    else:
        add_menu(path)
        mw.custom_menus[path].addAction(action) 
Example 34
Project: QMusic   Author: dragondjf   File: mainwindow.py    GNU Lesser General Public License v2.1 5 votes vote down vote up
def keyPressEvent(self, event):
        from controllers import configWorker, signalManager, mediaPlayer
        if configWorker.isShortcutEnable:
            modifier = QKeySequence(event.modifiers()).toString()
            keyString = QKeySequence(event.key()).toString()
            shortcut = modifier + keyString
            print shortcut
            if shortcut == configWorker.shortcut_preivous:
                signalManager.previousSong.emit()
            elif shortcut == configWorker.shortcut_next:
                signalManager.nextSong.emit()
            elif shortcut == configWorker.shortcut_volumnIncrease:
                signalManager.volumnIncrease.emit()
            elif shortcut == configWorker.shortcut_volumeDecrease:
                signalManager.volumnDecrease.emit()
            elif shortcut == configWorker.shortcut_playPause:
                signalManager.playToggle.emit(not mediaPlayer.playing)
            elif shortcut == configWorker.shortcut_simpleFullMode:
                signalManager.simpleFullToggle.emit()
            elif shortcut == configWorker.shortcut_miniFullMode:
                signalManager.miniFullToggle.emit()
            elif shortcut == configWorker.shortcut_hideShowWindow:
                signalManager.hideShowWindowToggle.emit()
            elif shortcut == configWorker.shortcut_hideShowDesktopLRC:
                signalManager.hideShowDesktopLrcToggle.emit()

        super(MainWindow, self).keyPressEvent(event) 
Example 35
Project: GeoMop   Author: GeoMop   File: keyboard_shortcuts.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, shortcut):
        """Initialize the class.

        :param str shortcut: string representation of a shortcut, use :samp:`+` to
           add modifiers
        """
        self.shortcut = shortcut
        self.key_sequence = QKeySequence(shortcut)
        self.qt_key = self._get_qt_code()
        self.scintilla_code = self._get_scintilla_code() 
Example 36
Project: poitagger   Author: dlr-eoc   File: __main__.py    GNU General Public License v3.0 5 votes vote down vote up
def createKeyCtrl(self,actionName, key):
        actionName.setShortcut(QtGui.QKeySequence(key))
        self.addAction(actionName) 
Example 37
Project: poitagger   Author: dlr-eoc   File: treeview.py    GNU General Public License v3.0 5 votes vote down vote up
def createKeyCtrl(self,actionName, key):
        actionName.setShortcut(QtGui.QKeySequence(key))
        self.addAction(actionName) 
Example 38
Project: EMFT_ARCHIVE   Author: theendsofinvention   File: base.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, key_sequence: QKeySequence, parent: QWidget, func: callable):
        QShortcut.__init__(self, key_sequence, parent)
        # noinspection PyUnresolvedReferences
        self.activated.connect(func) 
Example 39
Project: EMFT_ARCHIVE   Author: theendsofinvention   File: main_ui.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        # Fucking QMainWindow calls a general super().__init__ on every parent class, don't call them here !
        flags = Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.WindowCloseButtonHint
        flags = flags | Qt.WindowMinimizeButtonHint | Qt.WindowMaximizeButtonHint

        self.helpers = {}

        QMainWindow.__init__(
            self,
            flags=flags
        )

        self.resize(1024, 768)

        self.tabs = TabWidget()

        layout = VLayout(
            [
                self.tabs
            ]
        )

        layout.setContentsMargins(10, 10, 10, 10)

        window = Widget()
        window.setLayout(layout)

        self.setCentralWidget(window)

        self.setWindowIcon(QIcon(constant.DEFAULT_ICON))

        self.exit_shortcut = Shortcut(QKeySequence(Qt.Key_Escape), self, self.exit)

        self.setWindowTitle(
            '{} v{} - {}'.format(constant.APP_SHORT_NAME,
                                 __version__,
                                 constant.APP_RELEASE_NAME)) 
Example 40
Project: Anki-Night-Mode   Author: krassowski   File: menu.py    GNU General Public License v3.0 5 votes vote down vote up
def create_action(self, name, text, callback, checkable=False, shortcut=None):
        action = QAction(_(text), mw, checkable=checkable)

        if shortcut:
            toggle = QKeySequence(shortcut)
            action.setShortcut(toggle)

        if name in self.actions:
            message = 'Action {0} already exists'.format(name)
            raise Exception(message)

        self.actions[name] = action
        self.connections[action] = callback 
Example 41
Project: vimiv-qt   Author: karlch   File: eventhandler.py    GNU General Public License v3.0 5 votes vote down vote up
def _get_base_keysequence(event: QKeyEvent) -> SequenceT:
    """Get main keyname part of QKeyEvent.

    Converts special keys to usable names and uses event.text() otherwise. Is a sequence
    to allow prepending <shift> to special keys.

    Args:
        event: The emitted QKeyEvent.
    Returns:
        Name of the main key press escaping special keys.
    """
    special_keys = {
        Qt.Key_Space: "<space>",
        Qt.Key_Backtab: "<tab>",
        Qt.Key_Tab: "<tab>",
        Qt.Key_Escape: "<escape>",
        Qt.Key_Enter: "<enter>",
        Qt.Key_Return: "<return>",
        Qt.Key_Backspace: "<backspace>",
        Qt.Key_Left: "<left>",
        Qt.Key_Right: "<right>",
        Qt.Key_Up: "<up>",
        Qt.Key_Down: "<down>",
        Qt.Key_Home: "<home>",
        Qt.Key_End: "<end>",
        Qt.Key_PageUp: "<page-up>",
        Qt.Key_PageDown: "<page-down>",
        Qt.Key_Home: "<home>",
        Qt.Key_End: "<end>",
    }
    if event.key() in special_keys:
        # Parse shift here as the key does not support it otherwise
        text = special_keys[event.key()]  # type: ignore
        if event.modifiers() & Qt.ShiftModifier:  # type: ignore
            return "<shift>", text
        return (text,)
    if event.key() == Qt.Key_Colon:  # Required as : is the separator
        return ("<colon>",)
    if event.text().isprintable():
        return (event.text(),)
    return (QKeySequence(event.key()).toString().lower(),) 
Example 42
Project: PyReadon   Author: xflywind   File: Area.py    GNU General Public License v3.0 5 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) 
    
    # 鼠标左键翻页 
Example 43
Project: ggui   Author: gphoton-tools   File: targetManager.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, glue_parent: GlueApplication, target_change_callback: Callable[[str], None] = None):
        """Initializes gGui Target Manager
        If provided a dictionary of targets, in outlined gGui YAML structure, it will load those targets into the target manager

        :param glue_parent: The Glue instance that instantiated this object. Target Manager cannot be run outside a Glue context
        :param target_change_callback: Callback function to notify upon primary target change
        """
        super().__init__()
        self._glue_parent = glue_parent
        self._target_catalog = OrderedDict()
        self._primary_data = {}
        self._target_change_callbacks = []
        self._target_notes = None
        self._note_display_widget = target_note_display(self)

        # Initialize GUI Elements
        config = ConfigParser()
        config.read(resource_filename('ggui', 'ggui.conf'))   
        self.addWidget(QtWidgets.QLabel("gGui Target Manager: "))
        # Add Back Button
        self.addAction(QtGui.QIcon(resource_filename('ggui.icons', 'ArrowBack_transparent.png')), "Previous Target", self.previous_target)
        QtWidgets.QShortcut(QtGui.QKeySequence(config.get('Target Manager Shortcuts', 'previous_target', fallback='PgUp')), self).activated.connect(self.previous_target)
        # Add Combo Box
        self.QComboBox = QtWidgets.QComboBox(self)
        self.QComboBox.currentIndexChanged.connect(self.setPrimaryTarget)
        self.addWidget(self.QComboBox)
        # Add Forward Button
        self.addAction(QtGui.QIcon(resource_filename('ggui.icons', 'ArrowForward_transparent.png')), "Next Target", self.next_target)
        QtWidgets.QShortcut(QtGui.QKeySequence(config.get('Target Manager Shortcuts', 'next_target', fallback='PgDown')), self).activated.connect(self.next_target)
        # Add Info button
        self.addAction(QtGui.QIcon(resource_filename('ggui.icons', 'Information.svg')), "Target Information", self.show_targ_info)
        # Add Notes Button
        self.addAction(QtGui.QIcon(resource_filename('ggui.icons', 'Notepad.png')), "Target Notes", self._note_display_widget.show)

        # If the initializer wants to know about target changes, register its provided callback
        if target_change_callback:
            self.register_target_change_callback(target_change_callback) 
Example 44
Project: sibyl   Author: TheSchwa   File: client.py    GNU General Public License v3.0 5 votes vote down vote up
def make_item(self,menu,name,shortcut):
      """helper function to create a menu item and add it to the menu"""

      item = QtWidgets.QAction(name,self)
      item.setShortcut(QtGui.QKeySequence(shortcut))
      item.triggered.connect(self.cb_menu)
      menu.addAction(item)
      self.addAction(item) 
Example 45
Project: sibyl   Author: TheSchwa   File: client3.py    GNU General Public License v3.0 5 votes vote down vote up
def make_item(self,menu,name,shortcut):
      """helper function to create a menu item and add it to the menu"""

      item = QtWidgets.QAction(name,self)
      item.setShortcut(QtGui.QKeySequence(shortcut))
      item.triggered.connect(self.cb_menu)
      menu.addAction(item)
      self.addAction(item) 
Example 46
Project: Anki-Zoom   Author: krassowski   File: __init__.py    GNU General Public License v3.0 5 votes vote down vote up
def add_action(submenu, label, callback, shortcut=None):
    """Add action to menu"""
    action = QAction(_(label), mw)
    action.triggered.connect(callback)
    if shortcut:
        action.setShortcut(QKeySequence(shortcut))
    submenu.addAction(action) 
Example 47
Project: FeelUOwn   Author: feeluown   File: ui.py    GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, app):
        self._app = app
        self._layout = QVBoxLayout(app)
        self._top_separator = Separator(parent=app)
        self._bottom_separator = Separator(parent=app)
        self._splitter = QSplitter(app)

        # NOTE: 以位置命名的部件应该只用来组织界面布局,不要
        # 给其添加任何功能性的函数
        self.top_panel = TopPanel(app, app)
        self.bottom_panel = BottomPanel(app, app)
        self._left_panel_con = LeftPanel(self._app,)
        self.left_panel = self._left_panel_con.p
        self.right_panel = RightPanel(self._app, self._splitter)
        self.mpv_widget = MpvOpenGLWidget(self._app)
        self.mpv_widget.hide()

        # alias
        self.magicbox = self.bottom_panel.magicbox
        self.pc_panel = self.top_panel.pc_panel
        self.table_container = self.right_panel.table_container
        # backward compatible, old name is songs_table_container
        self.songs_table_container = self.table_container
        self.songs_table = self.table_container.songs_table
        self.back_btn = self.bottom_panel.back_btn
        self.forward_btn = self.bottom_panel.forward_btn
        self.toggle_video_btn = self.pc_panel.toggle_video_btn

        self.pc_panel.playlist_btn.clicked.connect(self.show_player_playlist)
        self.pc_panel.mv_btn.clicked.connect(self._play_mv)
        self.toggle_video_btn.clicked.connect(self._toggle_video_widget)
        self._app.player.video_format_changed.connect(
            self.on_video_format_changed, aioqueue=True)

        self._app.hotkey_mgr.registe(
            [QKeySequence('Ctrl+F'), QKeySequence(':'), QKeySequence('Alt+x')],
            self.magicbox.setFocus
        )

        self._setup_ui() 
Example 48
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1116.py    MIT License 5 votes vote down vote up
def qui_atn(self, ui_name, title, tip=None, icon=None, parent=None, key=None):
        self.uiList[ui_name] = QtWidgets.QAction(title, self)
        if icon!=None:
            self.uiList[ui_name].setIcon(QtGui.QIcon(icon))
        if tip !=None:
            self.uiList[ui_name].setStatusTip(tip)
        if key != None:
            self.uiList[ui_name].setShortcut(QtGui.QKeySequence(key))
        if parent !=None:
            if isinstance(parent, (str, unicode)) and parent in self.uiList.keys():
                self.uiList[parent].addAction(self.uiList[ui_name])
            elif isinstance(parent, QtWidgets.QMenu):
                parent.addAction(self.uiList[ui_name])
        return ui_name 
Example 49
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1116.py    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 50
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1116.py    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 ----