Python PyQt5.QtGui.QKeySequence() Examples

The following are 30 code examples of PyQt5.QtGui.QKeySequence(). 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 also want to check out all available functions/classes of the module PyQt5.QtGui , or try the search function .
Example #1
Source File: objectinspector.py    From IDASkins with MIT License 7 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
Source File: ClassName_1010.py    From universal_tool_template.py with 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 #3
Source File: universal_tool_template_1010.py    From universal_tool_template.py with 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 #4
Source File: main_window.py    From lxa5 with MIT License 6 votes vote down vote up
def create_action(self, text=None, slot=None, tip=None, shortcut=None):
        """
        This create actions for the File menu, things like
        Read Corpus, Rerun Corpus etc
        """
        action = QAction(text, self)
        if shortcut:
            action.setShortcut(shortcut)
        if tip:
            action.setToolTip(tip)
            action.setStatusTip(tip)
        if slot:
            # noinspection PyUnresolvedReferences
            action.triggered.connect(slot)
        if shortcut:
            # noinspection PyUnresolvedReferences
            QShortcut(QKeySequence(shortcut), self).activated.connect(slot)
        return action 
Example #5
Source File: MWTrackerViewer.py    From tierpsy-tracker with MIT License 6 votes vote down vote up
def __init__(self, ui):
        super().__init__(ui)
        self.wlab = WLAB
        self.label_type = 'worm_label'

        self.ui.pushButton_U.clicked.connect(
            partial(self._h_tag_worm, self.wlab['U']))
        self.ui.pushButton_W.clicked.connect(
            partial(self._h_tag_worm, self.wlab['WORM']))
        self.ui.pushButton_WS.clicked.connect(
            partial(self._h_tag_worm, self.wlab['WORMS']))
        self.ui.pushButton_B.clicked.connect(
            partial(self._h_tag_worm, self.wlab['BAD']))

        self.ui.pushButton_W.setShortcut(QKeySequence(Qt.Key_W))
        self.ui.pushButton_U.setShortcut(QKeySequence(Qt.Key_U))
        self.ui.pushButton_WS.setShortcut(QKeySequence(Qt.Key_C))
        self.ui.pushButton_B.setShortcut(QKeySequence(Qt.Key_B)) 
Example #6
Source File: util.py    From incremental-reading with ISC License 6 votes vote down vote up
def addMenuItem(path, text, function, keys=None):
    action = QAction(text, mw)

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

    action.triggered.connect(function)

    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:
        addMenu(path)
        mw.customMenus[path].addAction(action) 
Example #7
Source File: universal_tool_template_0803.py    From universal_tool_template.py with 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 #8
Source File: universal_tool_template_1110.py    From universal_tool_template.py with 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 #9
Source File: dmenu.py    From QMusic with 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 #10
Source File: universal_tool_template_1100.py    From universal_tool_template.py with 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 #11
Source File: __init__.py    From awesometts-anki-addon with GNU General Public License v3.0 6 votes vote down vote up
def window_shortcuts():
    """Enables shortcuts to launch windows."""

    def on_sequence_change(new_config):
        """Update sequences on configuration changes."""
        for key, sequence in sequences.items():
            new_sequence = QKeySequence(new_config['launch_' + key] or None)
            sequence.swap(new_sequence)

        try:
            aqt.mw.form.menuTools.findChild(gui.Action). \
                setShortcut(sequences['configurator'])
        except AttributeError:  # we do not have a config menu
            pass

    on_sequence_change(config)  # set config menu if created before we ran
    config.bind(['launch_' + key for key in sequences.keys()],
                on_sequence_change) 
Example #12
Source File: common.py    From awesometts-anki-addon with GNU General Public License v3.0 6 votes vote down vote up
def key_event_combo(event):
    """
    Given a key event, returns an integer representing the combination
    of keys that was pressed or released.

    Certain keys are blacklisted (see BLACKLIST) and key_event_combo()
    will return None if it sees these keys in the primary key() slot for
    an event. When used by themselves or exclusively with modifiers,
    these keys cause various problems: gibberish strings returned from
    QKeySequence#toString() and in menus, inability to capture the
    keystroke because the window manager does not forward it to Qt,
    ambiguous shortcuts where order would matter (e.g. Ctrl + Alt would
    produce a different numerical value than Alt + Ctrl, because the
    key codes for Alt and Ctrl are different from the modifier flag
    codes for Alt and Ctrl), and clashes with input navigation.
    """

    key = event.key()
    if key < 32 or key in key_event_combo.BLACKLIST:
        return None

    modifiers = event.modifiers()
    return key + sum(flag
                     for flag in key_event_combo.MOD_FLAGS
                     if modifiers & flag) 
Example #13
Source File: puzzle.py    From Miyamoto with GNU General Public License v3.0 6 votes vote down vote up
def setupMenus(self):
        fileMenu = self.menuBar().addMenu("&File")

        pixmap = QtGui.QPixmap(60,60)
        pixmap.fill(Qt.black)
        icon = QtGui.QIcon(pixmap)

        fileMenu.addAction("Import Tileset from file...", self.openTilesetfromFile, QtGui.QKeySequence.Open)
        fileMenu.addAction("Export Tileset...", self.saveTilesetAs, QtGui.QKeySequence.SaveAs)
        fileMenu.addAction("Import Image...", self.openImage, QtGui.QKeySequence('Ctrl+I'))
        fileMenu.addAction("Export Image...", self.saveImage, QtGui.QKeySequence('Ctrl+E'))
        fileMenu.addAction("Import Normal Map...", self.openNml, QtGui.QKeySequence('Ctrl+Shift+I'))
        fileMenu.addAction("Export Normal Map...", self.saveNml, QtGui.QKeySequence('Ctrl+Shift+E'))
        fileMenu.addAction("Save and Quit", self.saveTileset, QtGui.QKeySequence.Save)
        fileMenu.addAction("Quit", self.close, QtGui.QKeySequence('Ctrl-Q'))

        taskMenu = self.menuBar().addMenu("&Tasks")

        taskMenu.addAction("Toggle Normal Map", self.toggleNormal, QtGui.QKeySequence('Ctrl+Shift+N'))
        taskMenu.addAction("Show Tiles info...", self.showInfo, QtGui.QKeySequence('Ctrl+P'))
        taskMenu.addAction("Import object from file...", self.importObjFromFile, '')
        taskMenu.addAction("Export object...", self.saveObject, '')
        taskMenu.addAction("Export all objects...", self.saveAllObjects, '')
        taskMenu.addAction("Clear Collision Data", self.clearCollisions, QtGui.QKeySequence('Ctrl+Shift+Backspace'))
        taskMenu.addAction("Clear Object Data", self.clearObjects, QtGui.QKeySequence('Ctrl+Alt+Backspace')) 
Example #14
Source File: universal_tool_template_1112.py    From universal_tool_template.py with 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
Source File: universal_tool_template_1116.py    From universal_tool_template.py with 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 #16
Source File: universal_tool_template_1115.py    From universal_tool_template.py with 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
Source File: universal_tool_template_1020.py    From universal_tool_template.py with 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
Source File: UITranslator.py    From universal_tool_template.py with 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 #19
Source File: GearBox_template_1010.py    From universal_tool_template.py with 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 #20
Source File: MWTrackerViewer.py    From tierpsy-tracker with MIT License 5 votes vote down vote up
def __init__(self, ui):
        super().__init__(ui) 
        self.ui.pushButton_join.clicked.connect(self.joinTraj)
        self.ui.pushButton_split.clicked.connect(self.splitTraj)

        #SHORTCUTS
        self.ui.pushButton_join.setShortcut(QKeySequence(Qt.Key_J))
        self.ui.pushButton_split.setShortcut(QKeySequence(Qt.Key_S)) 
Example #21
Source File: universal_tool_template_1020.py    From universal_tool_template.py with MIT License 5 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']
        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() 
Example #22
Source File: universal_tool_template_2010.py    From universal_tool_template.py with 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) 
Example #23
Source File: ChatWidget.py    From PyQt with GNU General Public License v3.0 5 votes vote down vote up
def init(self):
        self.setUtf8(True)
        lexer = QsciLexerJSON(self)
        self.setLexer(lexer)
        self.setAutoCompletionCaseSensitivity(False)  # 忽略大小写
        self.setAutoCompletionSource(self.AcsAll)
        self.setAutoCompletionThreshold(1)  # 一个字符就弹出补全
        self.setAutoIndent(True)  # 自动缩进
        self.setBackspaceUnindents(True)
        self.setBraceMatching(self.StrictBraceMatch)
        self.setIndentationGuides(True)
        self.setIndentationsUseTabs(False)
        self.setIndentationWidth(4)
        self.setTabIndents(True)
        self.setTabWidth(4)
        self.setWhitespaceSize(1)
        self.setWhitespaceVisibility(self.WsVisible)
        self.setWhitespaceForegroundColor(Qt.gray)
        self.setWrapIndentMode(self.WrapIndentFixed)
        self.setWrapMode(self.WrapWord)
        # 折叠
        self.setFolding(self.BoxedTreeFoldStyle, 2)
        self.setFoldMarginColors(QColor("#676A6C"), QColor("#676A6D"))
        font = self.font() or QFont()
        font.setFamily("Consolas")
        font.setFixedPitch(True)
        font.setPointSize(13)
        self.setFont(font)
        self.setMarginsFont(font)
        self.fontmetrics = QFontMetrics(font)
        lexer.setFont(font)
        self.setMarginWidth(0, self.fontmetrics.width(str(self.lines())) + 6)
        self.setMarginLineNumbers(0, True)
        self.setMarginsBackgroundColor(QColor("gainsboro"))
        self.setMarginWidth(1, 0)
        self.setMarginWidth(2, 14)  # 折叠区域
        # 绑定自动补齐热键Alt+/
        completeKey = QShortcut(QKeySequence(Qt.ALT + Qt.Key_Slash), self)
        completeKey.setContext(Qt.WidgetShortcut)
        completeKey.activated.connect(self.autoCompleteFromAll) 
Example #24
Source File: GearBox_template_1010.py    From universal_tool_template.py with MIT License 5 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']
        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() 
Example #25
Source File: universal_tool_template_1115.py    From universal_tool_template.py with 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 #26
Source File: universal_tool_template_1115.py    From universal_tool_template.py with 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 #27
Source File: MWTrackerViewer.py    From tierpsy-tracker with MIT License 5 votes vote down vote up
def __init__(self, ui):
        
        super().__init__(ui)
        self.rois = [
            ROIWorm(
                self.ui.wormCanvas1,
                self.ui.comboBox_ROI1,
                self.ui.checkBox_ROI1
                ),
            ROIWorm(
                self.ui.wormCanvas2,
                self.ui.comboBox_ROI2,
                self.ui.checkBox_ROI2
                )
        ]

        
        self.ui.radioButton_ROI1.setShortcut(QKeySequence(Qt.Key_Up))
        self.ui.radioButton_ROI2.setShortcut(QKeySequence(Qt.Key_Down))


        self.ui.checkBox_ROI1.stateChanged.connect(partial(self._updateROI, self.rois[0]))
        self.ui.checkBox_ROI2.stateChanged.connect(partial(self._updateROI, self.rois[1]))

        self.ui.comboBox_ROI1.activated.connect(partial(self._updateROI, self.rois[0]))
        self.ui.comboBox_ROI2.activated.connect(partial(self._updateROI, self.rois[1]))
        
        # flags for RW and FF
        self.RW, self.FF = 1, 2
        self.ui.pushButton_ROI1_RW.clicked.connect(partial(self.roiRWFF, self.RW, self.rois[0]))
        self.ui.pushButton_ROI1_FF.clicked.connect(partial(self.roiRWFF, self.FF, self.rois[0]))
        self.ui.pushButton_ROI2_RW.clicked.connect(partial(self.roiRWFF, self.RW, self.rois[1]))
        self.ui.pushButton_ROI2_FF.clicked.connect(partial(self.roiRWFF, self.FF, self.rois[1])) 
Example #28
Source File: text_manager.py    From Grabber with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent=None):
        """Handles text files for batch downloads from a list of links."""

        super().__init__(parent=parent)

        # Denotes if the textfile is saved.
        self.SAVED = True

        self.textedit = QTextEdit()
        self.textedit.setObjectName('TextFileEdit')
        self.textedit.setFont(FONT_CONSOLAS)
        self.textedit.setAcceptRichText(False)
        self.textedit.verticalScrollBar().setObjectName('main')

        # Create load button and label.
        self.label = QLabel('Add videos to textfile:')
        self.loadButton = QPushButton('Load file')
        self.saveButton = QPushButton('Save file')
        self.saveButton.setDisabled(True)

        self.textedit.textChanged.connect(self.enable_saving)

        # Other functionality.
        self.shortcut = QShortcut(QKeySequence("Ctrl+S"), self.textedit)
        self.shortcut.activated.connect(self.saveButton.click)

        # Layout
        # Create horizontal layout.
        self.QH = QHBoxLayout()

        # Filling horizontal layout
        self.QH.addWidget(self.label)
        self.QH.addStretch(1)
        self.QH.addWidget(self.loadButton)
        self.QH.addWidget(self.saveButton)

        # Horizontal layout with a textedit and a button.
        self.VB = QVBoxLayout()
        self.VB.addLayout(self.QH)
        self.VB.addWidget(self.textedit)
        self.setLayout(self.VB) 
Example #29
Source File: binwindow.py    From MARA_Framework with GNU Lesser General Public License v3.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 #30
Source File: universal_tool_template_1112.py    From universal_tool_template.py with 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