本文整理汇总了Python中qtpy.QtWidgets.QAction.setToolTip方法的典型用法代码示例。如果您正苦于以下问题:Python QAction.setToolTip方法的具体用法?Python QAction.setToolTip怎么用?Python QAction.setToolTip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QAction
的用法示例。
在下文中一共展示了QAction.setToolTip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_action
# 需要导入模块: from qtpy.QtWidgets import QAction [as 别名]
# 或者: from qtpy.QtWidgets.QAction import setToolTip [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 shortcut is not None:
action.setShortcut(shortcut)
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)
#TODO: Hard-code all shortcuts and choose context=Qt.WidgetShortcut
# (this will avoid calling shortcuts from another dockwidget
# since the context thing doesn't work quite well with these widgets)
action.setShortcutContext(context)
return action
示例2: _init_toolbar
# 需要导入模块: from qtpy.QtWidgets import QAction [as 别名]
# 或者: from qtpy.QtWidgets.QAction import setToolTip [as 别名]
def _init_toolbar(self):
a = QAction(getIcon('ruler'), 'Scale bar', self)
a.setToolTip('Add scale bar')
a.setCheckable(True)
a.triggered.connect(self.scalebar)
self._actions['scalebar'] = a
self.insertAction(self._actions['configure_subplots'], a)
示例3: create_action
# 需要导入模块: from qtpy.QtWidgets import QAction [as 别名]
# 或者: from qtpy.QtWidgets.QAction import setToolTip [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