本文整理汇总了Python中qtpy.QtWidgets.QAction._shown_shortcut方法的典型用法代码示例。如果您正苦于以下问题:Python QAction._shown_shortcut方法的具体用法?Python QAction._shown_shortcut怎么用?Python QAction._shown_shortcut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QAction
的用法示例。
在下文中一共展示了QAction._shown_shortcut方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_action
# 需要导入模块: from qtpy.QtWidgets import QAction [as 别名]
# 或者: from qtpy.QtWidgets.QAction import _shown_shortcut [as 别名]
def create_action(parent, text, shortcut=None, icon=None, tip=None,
toggled=None, triggered=None, data=None, menurole=None,
context=Qt.WindowShortcut):
"""Create a QAction"""
action = QAction(text, parent)
if triggered is not None:
action.triggered.connect(triggered)
if toggled is not None:
action.toggled.connect(toggled)
action.setCheckable(True)
if icon is not None:
if is_text_string(icon):
icon = get_icon(icon)
action.setIcon(icon)
if tip is not None:
action.setToolTip(tip)
action.setStatusTip(tip)
if data is not None:
action.setData(to_qvariant(data))
if menurole is not None:
action.setMenuRole(menurole)
# Workround for Mac because setting context=Qt.WidgetShortcut
# there doesn't have any effect
if sys.platform == 'darwin':
action._shown_shortcut = None
if context == Qt.WidgetShortcut:
if shortcut is not None:
action._shown_shortcut = shortcut
else:
# This is going to be filled by
# main.register_shortcut
action._shown_shortcut = 'missing'
else:
if shortcut is not None:
action.setShortcut(shortcut)
action.setShortcutContext(context)
else:
if shortcut is not None:
action.setShortcut(shortcut)
action.setShortcutContext(context)
return action