本文整理汇总了Python中qtpy.QtWidgets.QPushButton.setToolTip方法的典型用法代码示例。如果您正苦于以下问题:Python QPushButton.setToolTip方法的具体用法?Python QPushButton.setToolTip怎么用?Python QPushButton.setToolTip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QPushButton
的用法示例。
在下文中一共展示了QPushButton.setToolTip方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_file_combobox
# 需要导入模块: from qtpy.QtWidgets import QPushButton [as 别名]
# 或者: from qtpy.QtWidgets.QPushButton import setToolTip [as 别名]
def create_file_combobox(self, text, choices, option, default=NoDefault,
tip=None, restart=False, filters=None,
adjust_to_contents=False,
default_line_edit=False):
"""choices: couples (name, key)"""
combobox = FileComboBox(self, adjust_to_contents=adjust_to_contents,
default_line_edit=default_line_edit)
combobox.restart_required = restart
combobox.label_text = text
edit = combobox.lineEdit()
edit.label_text = text
edit.restart_required = restart
self.lineedits[edit] = (option, default)
if tip is not None:
combobox.setToolTip(tip)
combobox.addItems(choices)
msg = _('Invalid file path')
self.validate_data[edit] = (osp.isfile, msg)
browse_btn = QPushButton(ima.icon('FileIcon'), '', self)
browse_btn.setToolTip(_("Select file"))
browse_btn.clicked.connect(lambda: self.select_file(edit, filters))
layout = QGridLayout()
layout.addWidget(combobox, 0, 0, 0, 9)
layout.addWidget(browse_btn, 0, 10)
layout.setContentsMargins(0, 0, 0, 0)
widget = QWidget(self)
widget.combobox = combobox
widget.browse_btn = browse_btn
widget.setLayout(layout)
return widget
示例2: create_browsedir
# 需要导入模块: from qtpy.QtWidgets import QPushButton [as 别名]
# 或者: from qtpy.QtWidgets.QPushButton import setToolTip [as 别名]
def create_browsedir(self, text, option, default=NoDefault, tip=None):
widget = self.create_lineedit(text, option, default,
alignment=Qt.Horizontal)
for edit in self.lineedits:
if widget.isAncestorOf(edit):
break
msg = _("Invalid directory path")
self.validate_data[edit] = (osp.isdir, msg)
browse_btn = QPushButton(ima.icon('DirOpenIcon'), '', self)
browse_btn.setToolTip(_("Select directory"))
browse_btn.clicked.connect(lambda: self.select_directory(edit))
layout = QHBoxLayout()
layout.addWidget(widget)
layout.addWidget(browse_btn)
layout.setContentsMargins(0, 0, 0, 0)
browsedir = QWidget(self)
browsedir.setLayout(layout)
return browsedir
示例3: ConfigDialog
# 需要导入模块: from qtpy.QtWidgets import QPushButton [as 别名]
# 或者: from qtpy.QtWidgets.QPushButton import setToolTip [as 别名]
class ConfigDialog(QDialog):
"""
Dialog window for specifying test configuration.
The window contains a combobox with all the frameworks, a line edit box for
specifying the working directory, a button to use a file browser for
selecting the directory, and OK and Cancel buttons. Initially, no framework
is selected and the OK button is disabled. Selecting a framework enables
the OK button.
"""
def __init__(self, frameworks, config, parent=None):
"""
Construct a dialog window.
Parameters
----------
frameworks : dict of (str, type)
Names of all supported frameworks with their associated class
(assumed to be a subclass of RunnerBase)
config : Config
Initial configuration
parent : QWidget
"""
super(ConfigDialog, self).__init__(parent)
self.setWindowTitle(_('Configure tests'))
layout = QVBoxLayout(self)
framework_layout = QHBoxLayout()
framework_label = QLabel(_('Test framework'))
framework_layout.addWidget(framework_label)
self.framework_combobox = QComboBox(self)
for ix, (name, runner) in enumerate(sorted(frameworks.items())):
installed = runner.is_installed()
if installed:
label = name
else:
label = '{} ({})'.format(name, _('not available'))
self.framework_combobox.addItem(label)
self.framework_combobox.model().item(ix).setEnabled(installed)
framework_layout.addWidget(self.framework_combobox)
layout.addLayout(framework_layout)
layout.addSpacing(10)
wdir_label = QLabel(_('Directory from which to run tests'))
layout.addWidget(wdir_label)
wdir_layout = QHBoxLayout()
self.wdir_lineedit = QLineEdit(self)
wdir_layout.addWidget(self.wdir_lineedit)
self.wdir_button = QPushButton(ima.icon('DirOpenIcon'), '', self)
self.wdir_button.setToolTip(_("Select directory"))
self.wdir_button.clicked.connect(lambda: self.select_directory())
wdir_layout.addWidget(self.wdir_button)
layout.addLayout(wdir_layout)
layout.addSpacing(20)
self.buttons = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel)
layout.addWidget(self.buttons)
self.buttons.accepted.connect(self.accept)
self.buttons.rejected.connect(self.reject)
self.ok_button = self.buttons.button(QDialogButtonBox.Ok)
self.ok_button.setEnabled(False)
self.framework_combobox.currentIndexChanged.connect(
self.framework_changed)
self.framework_combobox.setCurrentIndex(-1)
if config.framework:
index = self.framework_combobox.findText(config.framework)
if index != -1:
self.framework_combobox.setCurrentIndex(index)
self.wdir_lineedit.setText(config.wdir)
@Slot(int)
def framework_changed(self, index):
"""Called when selected framework changes."""
if index != -1:
self.ok_button.setEnabled(True)
def select_directory(self):
"""Display dialog for user to select working directory."""
basedir = to_text_string(self.wdir_lineedit.text())
if not osp.isdir(basedir):
basedir = getcwd()
title = _("Select directory")
directory = getexistingdirectory(self, title, basedir)
if directory:
self.wdir_lineedit.setText(directory)
def get_config(self):
"""
Return the test configuration specified by the user.
Returns
-------
#.........这里部分代码省略.........
示例4: __init__
# 需要导入模块: from qtpy.QtWidgets import QPushButton [as 别名]
# 或者: from qtpy.QtWidgets.QPushButton import setToolTip [as 别名]
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.dir = None
self.runconf = RunConfiguration()
firstrun_o = CONF.get('run', ALWAYS_OPEN_FIRST_RUN_OPTION, False)
# --- Interpreter ---
interpreter_group = QGroupBox(_("Console"))
interpreter_layout = QVBoxLayout()
interpreter_group.setLayout(interpreter_layout)
self.current_radio = QRadioButton(CURRENT_INTERPRETER)
interpreter_layout.addWidget(self.current_radio)
self.dedicated_radio = QRadioButton(DEDICATED_INTERPRETER)
interpreter_layout.addWidget(self.dedicated_radio)
self.systerm_radio = QRadioButton(SYSTERM_INTERPRETER)
interpreter_layout.addWidget(self.systerm_radio)
# --- General settings ----
common_group = QGroupBox(_("General settings"))
common_layout = QGridLayout()
common_group.setLayout(common_layout)
self.clear_var_cb = QCheckBox(CLEAR_ALL_VARIABLES)
common_layout.addWidget(self.clear_var_cb, 0, 0)
self.post_mortem_cb = QCheckBox(POST_MORTEM)
common_layout.addWidget(self.post_mortem_cb, 1, 0)
self.clo_cb = QCheckBox(_("Command line options:"))
common_layout.addWidget(self.clo_cb, 2, 0)
self.clo_edit = QLineEdit()
self.clo_cb.toggled.connect(self.clo_edit.setEnabled)
self.clo_edit.setEnabled(False)
common_layout.addWidget(self.clo_edit, 2, 1)
# --- Working directory ---
wdir_group = QGroupBox(_("Working Directory settings"))
wdir_layout = QVBoxLayout()
wdir_group.setLayout(wdir_layout)
self.file_dir_radio = QRadioButton(FILE_DIR)
wdir_layout.addWidget(self.file_dir_radio)
self.cwd_radio = QRadioButton(CW_DIR)
wdir_layout.addWidget(self.cwd_radio)
fixed_dir_layout = QHBoxLayout()
self.fixed_dir_radio = QRadioButton(FIXED_DIR)
fixed_dir_layout.addWidget(self.fixed_dir_radio)
self.wd_edit = QLineEdit()
self.fixed_dir_radio.toggled.connect(self.wd_edit.setEnabled)
self.wd_edit.setEnabled(False)
fixed_dir_layout.addWidget(self.wd_edit)
browse_btn = QPushButton(ima.icon('DirOpenIcon'), '', self)
browse_btn.setToolTip(_("Select directory"))
browse_btn.clicked.connect(self.select_directory)
fixed_dir_layout.addWidget(browse_btn)
wdir_layout.addLayout(fixed_dir_layout)
# --- System terminal ---
external_group = QGroupBox(_("External system terminal"))
external_group.setDisabled(True)
self.systerm_radio.toggled.connect(external_group.setEnabled)
external_layout = QGridLayout()
external_group.setLayout(external_layout)
self.interact_cb = QCheckBox(INTERACT)
external_layout.addWidget(self.interact_cb, 1, 0, 1, -1)
self.pclo_cb = QCheckBox(_("Command line options:"))
external_layout.addWidget(self.pclo_cb, 3, 0)
self.pclo_edit = QLineEdit()
self.pclo_cb.toggled.connect(self.pclo_edit.setEnabled)
self.pclo_edit.setEnabled(False)
self.pclo_edit.setToolTip(_("<b>-u</b> is added to the "
"other options you set here"))
external_layout.addWidget(self.pclo_edit, 3, 1)
# Checkbox to preserve the old behavior, i.e. always open the dialog
# on first run
hline = QFrame()
hline.setFrameShape(QFrame.HLine)
hline.setFrameShadow(QFrame.Sunken)
self.firstrun_cb = QCheckBox(ALWAYS_OPEN_FIRST_RUN % _("this dialog"))
self.firstrun_cb.clicked.connect(self.set_firstrun_o)
self.firstrun_cb.setChecked(firstrun_o)
layout = QVBoxLayout()
layout.addWidget(interpreter_group)
layout.addWidget(common_group)
layout.addWidget(wdir_group)
layout.addWidget(external_group)
layout.addWidget(hline)
layout.addWidget(self.firstrun_cb)
self.setLayout(layout)
示例5: __init__
# 需要导入模块: from qtpy.QtWidgets import QPushButton [as 别名]
# 或者: from qtpy.QtWidgets.QPushButton import setToolTip [as 别名]
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.current_radio = None
self.dedicated_radio = None
self.systerm_radio = None
self.runconf = RunConfiguration()
firstrun_o = CONF.get("run", ALWAYS_OPEN_FIRST_RUN_OPTION, False)
# --- General settings ----
common_group = QGroupBox(_("General settings"))
common_layout = QGridLayout()
common_group.setLayout(common_layout)
self.clo_cb = QCheckBox(_("Command line options:"))
common_layout.addWidget(self.clo_cb, 0, 0)
self.clo_edit = QLineEdit()
self.clo_cb.toggled.connect(self.clo_edit.setEnabled)
self.clo_edit.setEnabled(False)
common_layout.addWidget(self.clo_edit, 0, 1)
self.wd_cb = QCheckBox(_("Working directory:"))
common_layout.addWidget(self.wd_cb, 1, 0)
wd_layout = QHBoxLayout()
self.wd_edit = QLineEdit()
self.wd_cb.toggled.connect(self.wd_edit.setEnabled)
self.wd_edit.setEnabled(False)
wd_layout.addWidget(self.wd_edit)
browse_btn = QPushButton(ima.icon("DirOpenIcon"), "", self)
browse_btn.setToolTip(_("Select directory"))
browse_btn.clicked.connect(self.select_directory)
wd_layout.addWidget(browse_btn)
common_layout.addLayout(wd_layout, 1, 1)
self.post_mortem_cb = QCheckBox(_("Enter debugging mode when " "errors appear during execution"))
common_layout.addWidget(self.post_mortem_cb)
# --- Interpreter ---
interpreter_group = QGroupBox(_("Console"))
interpreter_layout = QVBoxLayout()
interpreter_group.setLayout(interpreter_layout)
self.current_radio = QRadioButton(CURRENT_INTERPRETER)
interpreter_layout.addWidget(self.current_radio)
self.dedicated_radio = QRadioButton(DEDICATED_INTERPRETER)
interpreter_layout.addWidget(self.dedicated_radio)
self.systerm_radio = QRadioButton(SYSTERM_INTERPRETER)
interpreter_layout.addWidget(self.systerm_radio)
# --- Dedicated interpreter ---
new_group = QGroupBox(_("Dedicated Python console"))
self.current_radio.toggled.connect(new_group.setDisabled)
new_layout = QGridLayout()
new_group.setLayout(new_layout)
self.interact_cb = QCheckBox(_("Interact with the Python " "console after execution"))
new_layout.addWidget(self.interact_cb, 1, 0, 1, -1)
self.show_kill_warning_cb = QCheckBox(_("Show warning when killing" " running process"))
new_layout.addWidget(self.show_kill_warning_cb, 2, 0, 1, -1)
self.pclo_cb = QCheckBox(_("Command line options:"))
new_layout.addWidget(self.pclo_cb, 3, 0)
self.pclo_edit = QLineEdit()
self.pclo_cb.toggled.connect(self.pclo_edit.setEnabled)
self.pclo_edit.setEnabled(False)
self.pclo_edit.setToolTip(_("<b>-u</b> is added to the " "other options you set here"))
new_layout.addWidget(self.pclo_edit, 3, 1)
# Checkbox to preserve the old behavior, i.e. always open the dialog
# on first run
hline = QFrame()
hline.setFrameShape(QFrame.HLine)
hline.setFrameShadow(QFrame.Sunken)
self.firstrun_cb = QCheckBox(ALWAYS_OPEN_FIRST_RUN % _("this dialog"))
self.firstrun_cb.clicked.connect(self.set_firstrun_o)
self.firstrun_cb.setChecked(firstrun_o)
layout = QVBoxLayout()
layout.addWidget(interpreter_group)
layout.addWidget(common_group)
layout.addWidget(new_group)
layout.addWidget(hline)
layout.addWidget(self.firstrun_cb)
self.setLayout(layout)
示例6: PlotNameWidget
# 需要导入模块: from qtpy.QtWidgets import QPushButton [as 别名]
# 或者: from qtpy.QtWidgets.QPushButton import setToolTip [as 别名]
class PlotNameWidget(QWidget):
"""A widget to display the plot name, and edit and close buttons
This widget is added to the table widget to support the renaming
and close buttons, as well as the direct renaming functionality.
"""
def __init__(self, presenter, plot_number, parent=None):
super(PlotNameWidget, self).__init__(parent)
self.presenter = presenter
self.plot_number = plot_number
self.mutex = QMutex()
self.line_edit = QLineEdit(self.presenter.get_plot_name_from_number(plot_number))
self.line_edit.setReadOnly(True)
self.line_edit.setFrame(False)
self.line_edit.setStyleSheet("* { background-color: rgba(0, 0, 0, 0); }")
self.line_edit.setAttribute(Qt.WA_TransparentForMouseEvents, True)
self.line_edit.editingFinished.connect(self.rename_plot)
shown_icon = get_icon('mdi.eye')
self.hide_button = QPushButton(shown_icon, "")
self.hide_button.setToolTip('Hide')
self.hide_button.setFlat(True)
self.hide_button.setMaximumWidth(self.hide_button.iconSize().width() * 5 / 3)
self.hide_button.clicked.connect(self.toggle_visibility)
rename_icon = get_icon('mdi.square-edit-outline')
self.rename_button = QPushButton(rename_icon, "")
self.rename_button.setToolTip('Rename')
self.rename_button.setFlat(True)
self.rename_button.setMaximumWidth(self.rename_button.iconSize().width() * 5 / 3)
self.rename_button.setCheckable(True)
self.rename_button.toggled.connect(self.rename_button_toggled)
close_icon = get_icon('mdi.close')
self.close_button = QPushButton(close_icon, "")
self.close_button.setToolTip('Delete')
self.close_button.setFlat(True)
self.close_button.setMaximumWidth(self.close_button.iconSize().width() * 5 / 3)
self.close_button.clicked.connect(lambda: self.close_pressed(self.plot_number))
self.layout = QHBoxLayout()
# Get rid of the top and bottom margins - the button provides
# some natural margin anyway. Get rid of right margin and
# reduce spacing to get buttons closer together.
self.layout.setContentsMargins(5, 0, 0, 0)
self.layout.setSpacing(0)
self.layout.addWidget(self.line_edit)
self.layout.addWidget(self.hide_button)
self.layout.addWidget(self.rename_button)
self.layout.addWidget(self.close_button)
self.layout.sizeHint()
self.setLayout(self.layout)
def set_plot_name(self, new_name):
"""
Sets the internally stored and displayed plot name
:param new_name: The name to set
"""
self.line_edit.setText(new_name)
def close_pressed(self, plot_number):
"""
Close the plot with the given name
:param plot_number: The unique number in GlobalFigureManager
"""
self.presenter.close_single_plot(plot_number)
def rename_button_toggled(self, checked):
"""
If the rename button is pressed from being unchecked then
make the line edit item editable
:param checked: True if the rename toggle is now pressed
"""
if checked:
self.toggle_plot_name_editable(True, toggle_rename_button=False)
def toggle_plot_name_editable(self, editable, toggle_rename_button=True):
"""
Set the line edit item to be editable or not editable. If
editable move the cursor focus to the editable name and
highlight it all.
:param editable: If true make the plot name editable, else
make it read only
:param toggle_rename_button: If true also toggle the rename
button state
"""
self.line_edit.setReadOnly(not editable)
self.line_edit.setAttribute(Qt.WA_TransparentForMouseEvents, not editable)
# This is a sneaky way to avoid the issue of two calls to
# this toggle method, by effectively disabling the button
# press in edit mode.
self.rename_button.setAttribute(Qt.WA_TransparentForMouseEvents, editable)
#.........这里部分代码省略.........