Python PySide.QtGui 模块,QKeySequence() 实例源码

我们从Python开源项目中,提取了以下29个代码示例,用于说明如何使用PySide.QtGui.QKeySequence()

项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
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])
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
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)
项目:ShortcutEditorNuke    作者:Ahuge    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        super(KeyboardWidget, self).__init__(*args, **kwargs)
        self.key_map = {}
        self.active_sequence = QtGui.QKeySequence()

        layout = QtGui.QVBoxLayout()

        # Setting up the context checkboxes above.
        self.init_context_box(layout)

        # Setting up the main keyboard view.
        self.init_keyboard_base(layout)

        # Setting up the bottom area. The search area and the extra keyboard buttons.

        self.setLayout(layout)
项目:android_malware_detection    作者:congyuandong    | 项目源码 | 文件源码
def createActions(self):
        self.xrefAct = QtGui.QAction("Xref from/to...", self,
#                shortcut=QtGui.QKeySequence("CTRL+B"),
                statusTip="List the references where this element is used",
                triggered=self.actionXref)
        self.expandAct = QtGui.QAction("Expand...", self,
                statusTip="Expand all the subtrees",
                triggered=self.actionExpand)
        self.collapseAct = QtGui.QAction("Collapse...", self,
                statusTip="Collapse all the subtrees",
                triggered=self.actionCollapse)
项目:android_malware_detection    作者:congyuandong    | 项目源码 | 文件源码
def createActions(self):
        self.xrefAct = QtGui.QAction("Xref from/to...", self,
#                shortcut=QtGui.QKeySequence("CTRL+B"),
                statusTip="List the references where this element is used",
                triggered=self.actionXref)
        self.expandAct = QtGui.QAction("Expand...", self,
                statusTip="Expand all the subtrees",
                triggered=self.actionExpand)
        self.collapseAct = QtGui.QAction("Collapse...", self,
                statusTip="Collapse all the subtrees",
                triggered=self.actionCollapse)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
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
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
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 )
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def setupMenu(self):
        self.quickMenu('file_menu;&File | setting_menu;&Setting | help_menu;&Help')
        cur_menu = self.uiList['setting_menu']
        for info in ['export', 'import','user']:
            title = info.title()
            self.quickMenuAction('{0}Config_atn'.format(info),'{0} Config (&{1})'.format(title,title[0]),'{0} Setting and Configuration.'.format(title),'{0}Config.png'.format(info), cur_menu)
            self.uiList['{0}Config_atn'.format(info)].setShortcut(QtGui.QKeySequence("Ctrl+{0}".format(title[0])))
        cur_menu.addSeparator()
        super(self.__class__,self).setupMenu()
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
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 ----
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def setupMenu(self):
        self.quickMenu('file_menu;&File | setting_menu;&Setting | help_menu;&Help')
        cur_menu = self.uiList['setting_menu']
        for info in ['export', 'import']:
            title = info.title()
            self.quickMenuAction('{0}Config_atn'.format(info),'{0} Config (&{1})'.format(title,title[0]),'{0} Setting and Configuration.'.format(title),'{0}Config.png'.format(info), cur_menu)
            self.uiList['{0}Config_atn'.format(info)].setShortcut(QtGui.QKeySequence("Ctrl+{0}".format(title[0])))
        cur_menu.addSeparator()
        super(self.__class__,self).setupMenu()
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
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 ----
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
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 info review
        cur_menu = self.uiList['help_menu']
        self.quickMenuAction('helpDeskMode_atnNone','Desk Mode - {}'.format(deskMode),'Desktop Running Mode - 0: Maya Mode; 1: Desktop Mode.','', cur_menu)
        self.quickMenuAction('helpQtMode_atnNone','PyQt4 Mode - {}'.format(qtMode),'Qt Library - 0: PySide; 1: PyQt4.','', cur_menu)
        self.quickMenuAction('helpTemplate_atnNone','Universal Tool Teamplate - {}'.format(tpl_ver),'based on Univeral Tool Template v7 by Shining Ying - http://shining-lucy.com','', 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)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
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()
        super(self.__class__,self).setupMenu()
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
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 ----
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
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 ----
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
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()
        super(self.__class__,self).setupMenu()
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
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 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)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def setupMenu(self):
        self.quickMenu('file_menu;&File | setting_menu;&Setting | help_menu;&Help')
        cur_menu = self.uiList['setting_menu']
        for info in ['export', 'import']:
            title = info.title()
            self.quickMenuAction('{0}Config_atn'.format(info),'{0} Config (&{1})'.format(title,title[0]),'{0} Setting and Configuration.'.format(title),'{0}Config.png'.format(info), cur_menu)
            self.uiList['{0}Config_atn'.format(info)].setShortcut(QtGui.QKeySequence("Ctrl+{0}".format(title[0])))
        cur_menu.addSeparator()
        super(self.__class__,self).setupMenu()
项目:DroidWatcher    作者:suemi994    | 项目源码 | 文件源码
def createActions(self):
        self.xrefAct = QtGui.QAction("Xref from...", self,
#                shortcut=QtGui.QKeySequence("CTRL+B"),
                statusTip="List the references where this element is used",
                triggered=self.actionXref)
        self.expandAct = QtGui.QAction("Expand...", self,
                statusTip="Expand all the subtrees",
                triggered=self.actionExpand)
        self.collapseAct = QtGui.QAction("Collapse...", self,
                statusTip="Collapse all the subtrees",
                triggered=self.actionCollapse)
项目:DroidWatcher    作者:suemi994    | 项目源码 | 文件源码
def createActions(self):
        self.xrefAct = QtGui.QAction("Xref from...", self,
#                shortcut=QtGui.QKeySequence("CTRL+B"),
                statusTip="List the references where this element is used",
                triggered=self.actionXref)
        self.expandAct = QtGui.QAction("Expand...", self,
                statusTip="Expand all the subtrees",
                triggered=self.actionExpand)
        self.collapseAct = QtGui.QAction("Collapse...", self,
                statusTip="Collapse all the subtrees",
                triggered=self.actionCollapse)
项目:ShortcutEditorNuke    作者:Ahuge    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super(KeySequenceObject, self).__init__(parent=parent)
        self._modifiers = QtGui.QApplication.keyboardModifiers()
        self._modifierlessAllowed = True  # True allows "b" as a shortcut, False requires shift/alt/ctrl/etc
        self._recording_sequence = QtGui.QKeySequence()
        self._seq = QtGui.QKeySequence()
        self._timer = QtCore.QTimer()
        self._timer.setSingleShot(True)
        self._is_recording = False
        self._timer.timeout.connect(self.done_recording)
项目:ShortcutEditorNuke    作者:Ahuge    | 项目源码 | 文件源码
def update_display(self):
        if self._is_recording:
            s = self._recording_sequence.toString(QtGui.QKeySequence.NativeText).replace('&', '&&')
            if self._modifiers:
                if s:
                    s += ","
                s += QtGui.QKeySequence(self._modifiers).toString(QtGui.QKeySequence.NativeText)
            elif self._recording_sequence.isEmpty():
                s = "Input"
        else:
            s = self._seq.toString(QtGui.QKeySequence.NativeText).replace('&', '&&')
        print s
项目:ShortcutEditorNuke    作者:Ahuge    | 项目源码 | 文件源码
def start_recording(self):
        self._is_recording = True
        self._recording_sequence = QtGui.QKeySequence()
        self._modifiers = int(QtGui.QApplication.keyboardModifiers() & (
            QtCore.Qt.SHIFT | QtCore.Qt.CTRL | QtCore.Qt.ALT | QtCore.Qt.META))
        self.grabKeyboard()
        self.update_display()
项目:ShortcutEditorNuke    作者:Ahuge    | 项目源码 | 文件源码
def str_to_key_int(key_name):
        seq = QtGui.QKeySequence(key_name)
        if seq.count() == 1:
            code = seq[0]
        else:
            assert seq.count() == 0
            seq = QtGui.QKeySequence(key_name + "+A")
            assert seq.count() == 1
            assert seq[0] > 65
            code = seq[0] - 65
        return code
项目:ShortcutEditorNuke    作者:Ahuge    | 项目源码 | 文件源码
def toggle_key(self, key_str):
        self.set_key(key_str, state=-1)
        self.active_sequence = QtGui.QKeySequence()
项目:ShortcutEditorNuke    作者:Ahuge    | 项目源码 | 文件源码
def set_sequence(self, key_sequence):
        func = self.set_key
        if key_sequence.matches(self.active_sequence) == QtGui.QKeySequence.SequenceMatch.NoMatch:
            self.clear_active_sequence()
            self.active_sequence = QtGui.QKeySequence(key_sequence.toString(QtGui.QKeySequence.NativeText))
        else:
            func = self.toggle_key

        key_name_list = self._key_str_list_from_sequence(self.active_sequence)
        print key_name_list
        for key_name in key_name_list:
            func(key_name)
        return True
项目:pcbre    作者:pcbre    | 项目源码 | 文件源码
def setupInvisibleActions(self):
        self.setupLayerSelection()

        def showToolSettings():
            if self.current_controller:
                self.current_controller.showSettingsDialog()

        a = QtGui.QAction("raise controls", self, triggered=showToolSettings)
        a.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Tab))
        self.addAction(a)

        def nudge(dx, dy):
            pos = QtGui.QCursor.pos()
            QtGui.QCursor.setPos(pos.x() + dx, pos.y() + dy)

        a = QtGui.QAction("nudge left", self, triggered=lambda: nudge(-1, 0))
        a.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Left))
        self.addAction(a)

        a = QtGui.QAction("nudge right", self, triggered=lambda: nudge(1, 0))
        a.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Right))
        self.addAction(a)

        a = QtGui.QAction("nudge up", self, triggered=lambda: nudge(0, -1))
        a.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Up))
        self.addAction(a)

        a = QtGui.QAction("nudge down", self, triggered=lambda: nudge(0, 1))
        a.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Down))
        self.addAction(a)
项目:pcbre    作者:pcbre    | 项目源码 | 文件源码
def setupLayerSelection(self):
        def _act(arg):
            selected_layer = arg - 1
            if selected_layer >= len(self.project.stackup.layers):
                return

            self.viewArea.viewState.current_layer = self.project.stackup.layers[selected_layer]

        for i in range(0, 10):
            # Closure
            def fn(i):
                a = QtGui.QAction("layer %d" % i, self, triggered=lambda: _act(i))
                a.setShortcut(QtGui.QKeySequence("%d" % i))
                self.addAction(a)
            fn(i)
项目:pcbre    作者:pcbre    | 项目源码 | 文件源码
def createViewToolbar(self):
        flipX = QtGui.QAction("Flip X", self, triggered=lambda: self.viewArea.viewState.flip(0))
        flipX.setShortcut(QtGui.QKeySequence("f"))
        flipX.setToolTip('f')

        flipY = QtGui.QAction("Flip Y", self, triggered=lambda: self.viewArea.viewState.flip(1))
        flipY.setShortcut(QtGui.QKeySequence("shift+f"))
        flipY.setToolTip('Shift+f')

        def rotater(deg):
            def _():
                self.viewArea.viewState.rotate(deg)
            return _

        self.rotate90L = QtGui.QAction("Rotate 90 (CCW)", self, triggered=rotater(-90))
        self.rotate90L.setShortcut(QtGui.QKeySequence("ctlr+shift+r"))
        self.rotate90L.setToolTip("Ctrl+Shift+r")

        self.rotate90R = QtGui.QAction("Rotate 90 (CW)", self, triggered=rotater(90))
        self.rotate90R.setShortcut(QtGui.QKeySequence("ctrl+r"))
        self.rotate90R.setToolTip("Ctrl+r")

        self.permute = QtGui.QAction("Cycle Image Draw Order", self, triggered=self.viewArea.viewState.permute_layer_order)
        self.permute.setShortcut(QtGui.QKeySequence("]"))
        self.permute.setToolTip("]")

        tb = self.addToolBar("View")
        tb.addAction(flipX)
        tb.addAction(flipY)
        tb.addAction(self.rotate90L)
        tb.addAction(self.rotate90R)
        tb.addAction(self.permute)

        self.flipX = flipX
        self.flipY = flipY