本文整理汇总了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()
示例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
示例3: shortcut
# 需要导入模块: from PyQt4.QtGui import QKeySequence [as 别名]
# 或者: from PyQt4.QtGui.QKeySequence import fromString [as 别名]
def shortcut(self):
return QKeySequence.fromString(self.text())