當前位置: 首頁>>代碼示例>>Python>>正文


Python QKeySequence.fromString方法代碼示例

本文整理匯總了Python中PyQt4.QtGui.QKeySequence.fromString方法的典型用法代碼示例。如果您正苦於以下問題:Python QKeySequence.fromString方法的具體用法?Python QKeySequence.fromString怎麽用?Python QKeySequence.fromString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt4.QtGui.QKeySequence的用法示例。


在下文中一共展示了QKeySequence.fromString方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: importShortcut

# 需要導入模塊: from PyQt4.QtGui import QKeySequence [as 別名]
# 或者: from PyQt4.QtGui.QKeySequence import fromString [as 別名]
def importShortcut(filename, widget, schemeWidget):
    """Loads shortcuts from a file"""
    try:
        d = ET.parse(filename)
        root = d.getroot()
        if root.tag != 'frescobaldi-shortcut':
            raise ValueError(_("No shortcuts found."))
    except Exception as e:
        QMessageBox.critical(widget, app.caption(_("Error")),
        _("Can't read from source:\n\n{url}\n\n{error}").format(
            url=filename, error=e))
        return
    
    schemeWidget.scheme.blockSignals(True)
    scheme = schemeWidget.addScheme(root.get('name'))
    schemeWidget.scheme.blockSignals(False)
    
    for col in root.findall('collection'):
        for name in col.findall('name'):
            shortcuts = [QKeySequence.fromString(shortcut.text) for shortcut in name.findall('shortcut')]
            item = widget.item(col.attrib['name'], name.attrib['name'])
            if item:
                item.setShortcuts(shortcuts, scheme)
            
    schemeWidget.disableDefault(False)
    schemeWidget.currentChanged.emit()
    schemeWidget.changed.emit()
開發者ID:uliska,項目名稱:frescobaldi,代碼行數:29,代碼來源:import_export.py

示例2: filter

# 需要導入模塊: from PyQt4.QtGui import QKeySequence [as 別名]
# 或者: from PyQt4.QtGui.QKeySequence import fromString [as 別名]
    def filter(self, filterString: str, item: QTreeWidgetItem) -> bool:
        visible = (filterString == "")
        columnCount = item.columnCount()
        for i in range(columnCount):
            if not visible:
                break
            text = item.text(i)
            if HostOsInfo.isMacHost():
                # accept e.g. Cmd+E in the filter. the text shows special fancy characters for Cmd
                if i == columnCount - 1:
                    key = QKeySequence.fromString(text, QKeySequence.NativeText)
                    if not key.isEmpty():
                        text = key.toString(QKeySequence.PortableText)
                        text.replace("Ctrl", "Cmd")
                        text.replace("Meta", "Ctrl")
                        text.replace("Alt", "Opt")

            if filterString.upper() in text.upper(): # case insensitive
                visible = True

        childCount = item.childCount()
        if childCount > 0:
        # force visibility if this item matches
            leafFilterString = "" if visible else filterString
            for i in range(childCount):
                citem = item.child(i) # QTreeWidgetItem
                if not filter(leafFilterString, citem):
                    visible = True

        item.setHidden(not visible)
        return not visible
開發者ID:nerdocs,項目名稱:MedUX,代碼行數:33,代碼來源:__init__.py

示例3: shortcut

# 需要導入模塊: from PyQt4.QtGui import QKeySequence [as 別名]
# 或者: from PyQt4.QtGui.QKeySequence import fromString [as 別名]
 def shortcut(self):
     return QKeySequence.fromString(self.text())
開發者ID:adjustive,項目名稱:enki,代碼行數:4,代碼來源:action_shortcut_editor.py


注:本文中的PyQt4.QtGui.QKeySequence.fromString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。