本文整理汇总了Python中qtpy.QtWidgets.QToolButton.setToolTip方法的典型用法代码示例。如果您正苦于以下问题:Python QToolButton.setToolTip方法的具体用法?Python QToolButton.setToolTip怎么用?Python QToolButton.setToolTip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QToolButton
的用法示例。
在下文中一共展示了QToolButton.setToolTip方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_toolbutton
# 需要导入模块: from qtpy.QtWidgets import QToolButton [as 别名]
# 或者: from qtpy.QtWidgets.QToolButton import setToolTip [as 别名]
def create_toolbutton(parent,
text=None,
shortcut=None,
icon=None,
tip=None,
toggled=None,
triggered=None,
autoraise=True,
text_beside_icon=False):
"""Create a QToolButton"""
button = QToolButton(parent)
if text is not None:
button.setText(text)
if icon is not None:
if is_text_string(icon):
icon = get_icon(icon)
button.setIcon(icon)
if text is not None or tip is not None:
button.setToolTip(text if tip is None else tip)
if text_beside_icon:
button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
button.setAutoRaise(autoraise)
if triggered is not None:
button.clicked.connect(triggered)
if toggled is not None:
button.toggled.connect(toggled)
button.setCheckable(True)
if shortcut is not None:
button.setShortcut(shortcut)
return button
示例2: NumpyArrayDialog
# 需要导入模块: from qtpy.QtWidgets import QToolButton [as 别名]
# 或者: from qtpy.QtWidgets.QToolButton import setToolTip [as 别名]
class NumpyArrayDialog(QDialog):
def __init__(self, parent=None, inline=True, offset=0, force_float=False):
QDialog.__init__(self, parent=parent)
self._parent = parent
self._text = None
self._valid = None
self._offset = offset
# TODO: add this as an option in the General Preferences?
self._force_float = force_float
self._help_inline = _("""
<b>Numpy Array/Matrix Helper</b><br>
Type an array in Matlab : <code>[1 2;3 4]</code><br>
or Spyder simplified syntax : <code>1 2;3 4</code>
<br><br>
Hit 'Enter' for array or 'Ctrl+Enter' for matrix.
<br><br>
<b>Hint:</b><br>
Use two spaces or two tabs to generate a ';'.
""")
self._help_table = _("""
<b>Numpy Array/Matrix Helper</b><br>
Enter an array in the table. <br>
Use Tab to move between cells.
<br><br>
Hit 'Enter' for array or 'Ctrl+Enter' for matrix.
<br><br>
<b>Hint:</b><br>
Use two tabs at the end of a row to move to the next row.
""")
# Widgets
self._button_warning = QToolButton()
self._button_help = HelperToolButton()
self._button_help.setIcon(ima.icon('MessageBoxInformation'))
style = """
QToolButton {
border: 1px solid grey;
padding:0px;
border-radius: 2px;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #f6f7fa, stop: 1 #dadbde);
}
"""
self._button_help.setStyleSheet(style)
if inline:
self._button_help.setToolTip(self._help_inline)
self._text = NumpyArrayInline(self)
self._widget = self._text
else:
self._button_help.setToolTip(self._help_table)
self._table = NumpyArrayTable(self)
self._widget = self._table
style = """
QDialog {
margin:0px;
border: 1px solid grey;
padding:0px;
border-radius: 2px;
}"""
self.setStyleSheet(style)
style = """
QToolButton {
margin:1px;
border: 0px solid grey;
padding:0px;
border-radius: 0px;
}"""
self._button_warning.setStyleSheet(style)
# widget setup
self.setWindowFlags(Qt.Window | Qt.Dialog | Qt.FramelessWindowHint)
self.setModal(True)
self.setWindowOpacity(0.90)
self._widget.setMinimumWidth(200)
# layout
self._layout = QHBoxLayout()
self._layout.addWidget(self._widget)
self._layout.addWidget(self._button_warning, 1, Qt.AlignTop)
self._layout.addWidget(self._button_help, 1, Qt.AlignTop)
self.setLayout(self._layout)
self._widget.setFocus()
def keyPressEvent(self, event):
"""
Qt override.
"""
QToolTip.hideText()
ctrl = event.modifiers() & Qt.ControlModifier
if event.key() in [Qt.Key_Enter, Qt.Key_Return]:
if ctrl:
#.........这里部分代码省略.........