本文整理汇总了Python中qtpy.QtWidgets.QCheckBox.isChecked方法的典型用法代码示例。如果您正苦于以下问题:Python QCheckBox.isChecked方法的具体用法?Python QCheckBox.isChecked怎么用?Python QCheckBox.isChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QCheckBox
的用法示例。
在下文中一共展示了QCheckBox.isChecked方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dialog
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import isChecked [as 别名]
def dialog(title, text, icon, setting=None, default=None):
if not getattr(settings, setting.upper()):
return True
check = QCheckBox()
check.setText('Dont show this message again (can be reset via the preferences)')
info = QMessageBox()
info.setIcon(icon)
info.setText(title)
info.setInformativeText(text)
info.setCheckBox(check)
info.setStandardButtons(info.Cancel | info.Ok)
if default == 'Cancel':
info.setDefaultButton(info.Cancel)
result = info.exec_()
if result == info.Cancel:
return False
if check.isChecked():
setattr(settings, setting.upper(), False)
save_settings()
return True
示例2: FontLayout
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import isChecked [as 别名]
class FontLayout(QGridLayout):
"""Font selection"""
def __init__(self, value, parent=None):
QGridLayout.__init__(self)
font = tuple_to_qfont(value)
assert font is not None
# Font family
self.family = QFontComboBox(parent)
self.family.setCurrentFont(font)
self.addWidget(self.family, 0, 0, 1, -1)
# Font size
self.size = QComboBox(parent)
self.size.setEditable(True)
sizelist = list(range(6, 12)) + list(range(12, 30, 2)) + [36, 48, 72]
size = font.pointSize()
if size not in sizelist:
sizelist.append(size)
sizelist.sort()
self.size.addItems([str(s) for s in sizelist])
self.size.setCurrentIndex(sizelist.index(size))
self.addWidget(self.size, 1, 0)
# Italic or not
self.italic = QCheckBox(_("Italic"), parent)
self.italic.setChecked(font.italic())
self.addWidget(self.italic, 1, 1)
# Bold or not
self.bold = QCheckBox(_("Bold"), parent)
self.bold.setChecked(font.bold())
self.addWidget(self.bold, 1, 2)
def get_font(self):
font = self.family.currentFont()
font.setItalic(self.italic.isChecked())
font.setBold(self.bold.isChecked())
font.setPointSize(int(self.size.currentText()))
return qfont_to_tuple(font)
示例3: MessageCheckBox
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import isChecked [as 别名]
class MessageCheckBox(QMessageBox):
"""
A QMessageBox derived widget that includes a QCheckBox aligned to the right
under the message and on top of the buttons.
"""
def __init__(self, *args, **kwargs):
super(MessageCheckBox, self).__init__(*args, **kwargs)
self._checkbox = QCheckBox()
# Set layout to include checkbox
size = 9
check_layout = QVBoxLayout()
check_layout.addItem(QSpacerItem(size, size))
check_layout.addWidget(self._checkbox, 0, Qt.AlignRight)
check_layout.addItem(QSpacerItem(size, size))
# Access the Layout of the MessageBox to add the Checkbox
layout = self.layout()
if PYQT5:
layout.addLayout(check_layout, 1, 2)
else:
layout.addLayout(check_layout, 1, 1)
# --- Public API
# Methods to access the checkbox
def is_checked(self):
return self._checkbox.isChecked()
def set_checked(self, value):
return self._checkbox.setChecked(value)
def set_check_visible(self, value):
self._checkbox.setVisible(value)
def is_check_visible(self):
self._checkbox.isVisible()
def checkbox_text(self):
self._checkbox.text()
def set_checkbox_text(self, text):
self._checkbox.setText(text)
示例4: _SaveDialog
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import isChecked [as 别名]
class _SaveDialog(QFileDialog):
def __init__(self, parent):
QFileDialog.__init__(self, parent)
self.setFileMode(QFileDialog.AnyFile)
self.setAcceptMode(QFileDialog.AcceptSave)
# Widgets
self._chk_tight = QCheckBox('Tight layout')
self._txt_dpi = QSpinBox()
self._txt_dpi.setRange(1, 10000)
self._txt_dpi.setSingleStep(50)
self._txt_dpi.setSuffix('dpi')
self._txt_dpi.setValue(100)
# Layouts
layout = self.layout()
lyt_extras = QHBoxLayout()
lyt_extras.addWidget(QLabel('Extra options'))
lyt_extras.addWidget(self._chk_tight)
lyt_extras.addWidget(QLabel('Resolution'))
lyt_extras.addWidget(self._txt_dpi)
layout.addLayout(lyt_extras, layout.rowCount(), 0, 1, layout.columnCount())
self.setLayout(layout)
def tightLayout(self):
return self._chk_tight.isChecked()
def setTightLayout(self, tight):
self._chk_tight.setChecked(tight)
def dpi(self):
return self._txt_dpi.value()
def setDpi(self, dpi):
self._txt_dpi.setValue(dpi)
示例5: ColorbarWidget
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import isChecked [as 别名]
class ColorbarWidget(QWidget):
colorbarChanged = Signal() # The parent should simply redraw their canvas
def __init__(self, parent=None):
super(ColorbarWidget, self).__init__(parent)
self.setWindowTitle("Colorbar")
self.setMaximumWidth(200)
self.dval = QDoubleValidator()
self.cmin = QLineEdit()
self.cmin_value = 0
self.cmin.setMaximumWidth(100)
self.cmin.editingFinished.connect(self.clim_changed)
self.cmin_layout = QHBoxLayout()
self.cmin_layout.addStretch()
self.cmin_layout.addWidget(self.cmin)
self.cmin_layout.addStretch()
self.cmax = QLineEdit()
self.cmax_value = 1
self.cmax.setMaximumWidth(100)
self.cmax.editingFinished.connect(self.clim_changed)
self.cmin.setValidator(self.dval)
self.cmax.setValidator(self.dval)
self.cmax_layout = QHBoxLayout()
self.cmax_layout.addStretch()
self.cmax_layout.addWidget(self.cmax)
self.cmax_layout.addStretch()
self.norm_layout = QHBoxLayout()
self.norm = QComboBox()
self.norm.addItems(NORM_OPTS)
self.norm.currentIndexChanged.connect(self.norm_changed)
self.powerscale = QLineEdit()
self.powerscale_value = 2
self.powerscale.setText("2")
self.powerscale.setValidator(QDoubleValidator(0.001,100,3))
self.powerscale.setMaximumWidth(50)
self.powerscale.editingFinished.connect(self.norm_changed)
self.powerscale.hide()
self.powerscale_label = QLabel("n=")
self.powerscale_label.hide()
self.norm_layout.addStretch()
self.norm_layout.addWidget(self.norm)
self.norm_layout.addStretch()
self.norm_layout.addWidget(self.powerscale_label)
self.norm_layout.addWidget(self.powerscale)
self.autoscale = QCheckBox("Autoscaling")
self.autoscale.setChecked(True)
self.autoscale.stateChanged.connect(self.update_clim)
self.canvas = FigureCanvas(Figure())
if parent:
# Set facecolor to match parent
self.canvas.figure.set_facecolor(parent.palette().window().color().getRgbF())
self.ax = self.canvas.figure.add_axes([0.4,0.05,0.2,0.9])
# layout
self.layout = QVBoxLayout(self)
self.layout.addLayout(self.cmax_layout)
self.layout.addWidget(self.canvas, stretch=1)
self.layout.addLayout(self.cmin_layout)
self.layout.addLayout(self.norm_layout)
self.layout.addWidget(self.autoscale)
def set_mappable(self, mappable):
"""
When a new plot is created this method should be called with the new mappable
"""
self.ax.clear()
self.colorbar = Colorbar(ax=self.ax, mappable=mappable)
self.cmin_value, self.cmax_value = self.colorbar.get_clim()
self.update_clim_text()
self.redraw()
def norm_changed(self):
"""
Called when a different normalization is selected
"""
idx = self.norm.currentIndex()
if NORM_OPTS[idx] == 'Power':
self.powerscale.show()
self.powerscale_label.show()
else:
self.powerscale.hide()
self.powerscale_label.hide()
self.colorbar.mappable.set_norm(self.get_norm())
self.colorbarChanged.emit()
def get_norm(self):
"""
This will create a matplotlib.colors.Normalize from selected idx, limits and powerscale
"""
idx = self.norm.currentIndex()
if self.autoscale.isChecked():
#.........这里部分代码省略.........
示例6: RunConfigOptions
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import isChecked [as 别名]
#.........这里部分代码省略.........
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)
def select_directory(self):
"""Select directory"""
basedir = to_text_string(self.wd_edit.text())
if not osp.isdir(basedir):
basedir = getcwd_or_home()
directory = getexistingdirectory(self, _("Select directory"), basedir)
if directory:
self.wd_edit.setText(directory)
self.dir = directory
def set(self, options):
self.runconf.set(options)
self.clo_cb.setChecked(self.runconf.args_enabled)
self.clo_edit.setText(self.runconf.args)
if self.runconf.current:
self.current_radio.setChecked(True)
elif self.runconf.systerm:
self.systerm_radio.setChecked(True)
else:
self.dedicated_radio.setChecked(True)
self.interact_cb.setChecked(self.runconf.interact)
self.post_mortem_cb.setChecked(self.runconf.post_mortem)
self.pclo_cb.setChecked(self.runconf.python_args_enabled)
self.pclo_edit.setText(self.runconf.python_args)
self.clear_var_cb.setChecked(self.runconf.clear_namespace)
self.file_dir_radio.setChecked(self.runconf.file_dir)
self.cwd_radio.setChecked(self.runconf.cw_dir)
self.fixed_dir_radio.setChecked(self.runconf.fixed_dir)
self.dir = self.runconf.dir
self.wd_edit.setText(self.dir)
def get(self):
self.runconf.args_enabled = self.clo_cb.isChecked()
self.runconf.args = to_text_string(self.clo_edit.text())
self.runconf.current = self.current_radio.isChecked()
self.runconf.systerm = self.systerm_radio.isChecked()
self.runconf.interact = self.interact_cb.isChecked()
self.runconf.post_mortem = self.post_mortem_cb.isChecked()
self.runconf.python_args_enabled = self.pclo_cb.isChecked()
self.runconf.python_args = to_text_string(self.pclo_edit.text())
self.runconf.clear_namespace = self.clear_var_cb.isChecked()
self.runconf.file_dir = self.file_dir_radio.isChecked()
self.runconf.cw_dir = self.cwd_radio.isChecked()
self.runconf.fixed_dir = self.fixed_dir_radio.isChecked()
self.runconf.dir = self.wd_edit.text()
return self.runconf.get()
def is_valid(self):
wdir = to_text_string(self.wd_edit.text())
if not self.fixed_dir_radio.isChecked() or osp.isdir(wdir):
return True
else:
QMessageBox.critical(self, _("Run configuration"),
_("The following working directory is "
"not valid:<br><b>%s</b>") % wdir)
return False
def set_firstrun_o(self):
CONF.set('run', ALWAYS_OPEN_FIRST_RUN_OPTION,
self.firstrun_cb.isChecked())
示例7: FindReplace
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import isChecked [as 别名]
#.........这里部分代码省略.........
QWebEngineView = type(None)
self.words_button.setVisible(not isinstance(editor, QWebEngineView))
self.re_button.setVisible(not isinstance(editor, QWebEngineView))
from spyderlib.widgets.sourcecode.codeeditor import CodeEditor
self.is_code_editor = isinstance(editor, CodeEditor)
self.highlight_button.setVisible(self.is_code_editor)
if refresh:
self.refresh()
if self.isHidden() and editor is not None:
self.clear_matches()
@Slot()
def find_next(self):
"""Find next occurrence"""
state = self.find(changed=False, forward=True, rehighlight=False)
self.editor.setFocus()
self.search_text.add_current_text()
return state
@Slot()
def find_previous(self):
"""Find previous occurrence"""
state = self.find(changed=False, forward=False, rehighlight=False)
self.editor.setFocus()
return state
def text_has_been_edited(self, text):
"""Find text has been edited (this slot won't be triggered when
setting the search pattern combo box text programmatically"""
self.find(changed=True, forward=True, start_highlight_timer=True)
def highlight_matches(self):
"""Highlight found results"""
if self.is_code_editor and self.highlight_button.isChecked():
text = self.search_text.currentText()
words = self.words_button.isChecked()
regexp = self.re_button.isChecked()
self.editor.highlight_found_results(text, words=words,
regexp=regexp)
def clear_matches(self):
"""Clear all highlighted matches"""
if self.is_code_editor:
self.editor.clear_found_results()
def find(self, changed=True, forward=True,
rehighlight=True, start_highlight_timer=False):
"""Call the find function"""
text = self.search_text.currentText()
if len(text) == 0:
self.search_text.lineEdit().setStyleSheet("")
return None
else:
case = self.case_button.isChecked()
words = self.words_button.isChecked()
regexp = self.re_button.isChecked()
found = self.editor.find_text(text, changed, forward, case=case,
words=words, regexp=regexp)
self.search_text.lineEdit().setStyleSheet(self.STYLE[found])
if self.is_code_editor and found:
if rehighlight or not self.editor.found_results:
self.highlight_timer.stop()
if start_highlight_timer:
self.highlight_timer.start()
else:
self.highlight_matches()
示例8: LSPServerEditor
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import isChecked [as 别名]
#.........这里部分代码省略.........
self.cmd_input.setStyleSheet(
"QLineEdit{border: 1px solid red;}")
self.cmd_input.setToolTip('Command must be non empty')
return
if find_program(cmd_text) is None:
self.button_ok.setEnabled(False)
self.cmd_input.setStyleSheet(
"QLineEdit{border: 1px solid red;}")
self.cmd_input.setToolTip('Program was not found '
'on your system')
return
else:
self.cmd_input.setStyleSheet(
"QLineEdit{border: 1px solid green;}")
self.cmd_input.setToolTip('Program was found on your system')
self.button_ok.setEnabled(True)
try:
json.loads(self.conf_input.toPlainText())
try:
self.json_label.setText(self.JSON_VALID)
except:
pass
except (ValueError, json.decoder.JSONDecodeError):
try:
self.json_label.setText(self.JSON_INVALID)
self.button_ok.setEnabled(False)
except:
pass
def form_status(self, status):
self.host_input.setEnabled(status)
self.port_spinner.setEnabled(status)
self.external_cb.setEnabled(status)
self.cmd_input.setEnabled(status)
self.args_input.setEnabled(status)
self.conf_input.setEnabled(status)
self.json_label.setVisible(status)
@Slot()
def lang_selection_changed(self):
idx = self.lang_cb.currentIndex()
if idx == 0:
self.set_defaults()
self.form_status(False)
self.button_ok.setEnabled(False)
else:
server = self.parent.get_server_by_lang(LSP_LANGUAGES[idx - 1])
self.form_status(True)
if server is not None:
self.host_input.setText(server.host)
self.port_spinner.setValue(server.port)
self.external_cb.setChecked(server.external)
self.cmd_input.setText(server.cmd)
self.args_input.setText(server.args)
self.conf_input.set_text(json.dumps(server.configurations))
self.json_label.setText(self.JSON_VALID)
self.button_ok.setEnabled(True)
else:
self.set_defaults()
def set_defaults(self):
self.cmd_input.setStyleSheet('')
self.host_input.setStyleSheet('')
self.host_input.setText(self.DEFAULT_HOST)
self.port_spinner.setValue(self.DEFAULT_PORT)
self.external_cb.setChecked(self.DEFAULT_EXTERNAL)
self.cmd_input.setText(self.DEFAULT_CMD)
self.args_input.setText(self.DEFAULT_ARGS)
self.conf_input.set_text(self.DEFAULT_CONFIGURATION)
self.json_label.setText(self.JSON_VALID)
@Slot(bool)
@Slot(int)
def set_local_options(self, enabled):
self.external = enabled
self.cmd_input.setEnabled(True)
self.args_input.setEnabled(True)
if enabled:
self.cmd_input.setEnabled(False)
self.cmd_input.setStyleSheet('')
self.args_input.setEnabled(False)
try:
self.validate()
except:
pass
def get_options(self):
language_idx = self.lang_cb.currentIndex()
language = LSP_LANGUAGES[language_idx - 1]
host = self.host_input.text()
port = int(self.port_spinner.value())
external = self.external_cb.isChecked()
args = self.args_input.text()
cmd = self.cmd_input.text()
configurations = json.loads(self.conf_input.toPlainText())
server = LSPServer(language=language.lower(), cmd=cmd, args=args,
host=host, port=port, external=external,
configurations=configurations)
return server
示例9: SampleLogsView
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import isChecked [as 别名]
#.........这里部分代码省略.........
layout_stats.addRow('Min:', self.stats_widgets["minimum"])
layout_stats.addRow('Max:', self.stats_widgets["maximum"])
layout_stats.addRow('Mean:', self.stats_widgets["mean"])
layout_stats.addRow('Median:', self.stats_widgets["median"])
layout_stats.addRow('Std Dev:', self.stats_widgets["standard_deviation"])
layout_stats.addRow('Time Avg:', self.stats_widgets["time_mean"])
layout_stats.addRow('Time Std Dev:', self.stats_widgets["time_standard_deviation"])
layout_stats.addRow('Duration:', self.stats_widgets["duration"])
layout_right.addLayout(layout_stats)
frame_right.setLayout(layout_right)
self.addWidget(frame_right)
self.setStretchFactor(0,1)
self.resize(1200,800)
self.show()
def tableMenu(self, event):
"""Right click menu for table, can plot or print selected logs"""
menu = QMenu(self)
plotAction = menu.addAction("Plot selected")
plotAction.triggered.connect(self.presenter.new_plot_logs)
plotAction = menu.addAction("Print selected")
plotAction.triggered.connect(self.presenter.print_selected_logs)
menu.exec_(event.globalPos())
def set_model(self, model):
"""Set the model onto the table"""
self.model = model
self.table.setModel(self.model)
self.table.resizeColumnsToContents()
self.table.horizontalHeader().setSectionResizeMode(2, QHeaderView.Stretch)
def plot_selected_logs(self, ws, exp, rows):
"""Update the plot with the selected rows"""
self.ax.clear()
self.create_ax_by_rows(self.ax, ws, exp, rows)
self.fig.canvas.draw()
def new_plot_selected_logs(self, ws, exp, rows):
"""Create a new plot, in a separate window for selected rows"""
fig, ax = plt.subplots(subplot_kw={'projection': 'mantid'})
self.create_ax_by_rows(ax, ws, exp, rows)
fig.show()
def create_ax_by_rows(self, ax, ws, exp, rows):
"""Creates the plots for given rows onto axis ax"""
for row in rows:
log_text = self.get_row_log_name(row)
ax.plot(ws,
LogName=log_text,
label=log_text,
marker='.',
FullTime=not self.full_time.isChecked(),
ExperimentInfo=exp)
ax.set_ylabel('')
if ax.get_legend_handles_labels()[0]:
ax.legend()
def get_row_log_name(self, i):
"""Returns the log name of particular row"""
return str(self.model.item(i, 0).text())
def get_exp(self):
"""Get set experiment info number"""
return self.experimentInfo.value()
def get_selected_row_indexes(self):
"""Return a list of selected row from table"""
return [row.row() for row in self.table.selectionModel().selectedRows()]
def set_selected_rows(self, rows):
"""Set seleceted rows in table"""
mode = QItemSelectionModel.Select | QItemSelectionModel.Rows
for row in rows:
self.table.selectionModel().select(self.model.index(row, 0), mode)
def create_stats_widgets(self):
"""Creates the statistics widgets"""
self.stats_widgets = {"minimum": QLineEdit(),
"maximum": QLineEdit(),
"mean": QLineEdit(),
"median": QLineEdit(),
"standard_deviation": QLineEdit(),
"time_mean": QLineEdit(),
"time_standard_deviation": QLineEdit(),
"duration": QLineEdit()}
for widget in self.stats_widgets.values():
widget.setReadOnly(True)
def set_statistics(self, stats):
"""Updates the statistics widgets from stats dictionary"""
for param in self.stats_widgets.keys():
self.stats_widgets[param].setText('{:.6}'.format(getattr(stats, param)))
def clear_statistics(self):
"""Clears the values in statistics widgets"""
for widget in self.stats_widgets.values():
widget.clear()
示例10: RunConfigOptions
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import isChecked [as 别名]
#.........这里部分代码省略.........
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)
def select_directory(self):
"""Select directory"""
basedir = to_text_string(self.wd_edit.text())
if not osp.isdir(basedir):
basedir = getcwd()
directory = getexistingdirectory(self, _("Select directory"), basedir)
if directory:
self.wd_edit.setText(directory)
self.wd_cb.setChecked(True)
def set(self, options):
self.runconf.set(options)
self.clo_cb.setChecked(self.runconf.args_enabled)
self.clo_edit.setText(self.runconf.args)
self.wd_cb.setChecked(self.runconf.wdir_enabled)
self.wd_edit.setText(self.runconf.wdir)
if self.runconf.current:
self.current_radio.setChecked(True)
elif self.runconf.systerm:
self.systerm_radio.setChecked(True)
else:
self.dedicated_radio.setChecked(True)
self.interact_cb.setChecked(self.runconf.interact)
self.show_kill_warning_cb.setChecked(self.runconf.show_kill_warning)
self.post_mortem_cb.setChecked(self.runconf.post_mortem)
self.pclo_cb.setChecked(self.runconf.python_args_enabled)
self.pclo_edit.setText(self.runconf.python_args)
def get(self):
self.runconf.args_enabled = self.clo_cb.isChecked()
self.runconf.args = to_text_string(self.clo_edit.text())
self.runconf.wdir_enabled = self.wd_cb.isChecked()
self.runconf.wdir = to_text_string(self.wd_edit.text())
self.runconf.current = self.current_radio.isChecked()
self.runconf.systerm = self.systerm_radio.isChecked()
self.runconf.interact = self.interact_cb.isChecked()
self.runconf.show_kill_warning = self.show_kill_warning_cb.isChecked()
self.runconf.post_mortem = self.post_mortem_cb.isChecked()
self.runconf.python_args_enabled = self.pclo_cb.isChecked()
self.runconf.python_args = to_text_string(self.pclo_edit.text())
return self.runconf.get()
def is_valid(self):
wdir = to_text_string(self.wd_edit.text())
if not self.wd_cb.isChecked() or osp.isdir(wdir):
return True
else:
QMessageBox.critical(
self, _("Run configuration"), _("The following working directory is " "not valid:<br><b>%s</b>") % wdir
)
return False
def set_firstrun_o(self):
CONF.set("run", ALWAYS_OPEN_FIRST_RUN_OPTION, self.firstrun_cb.isChecked())
示例11: KernelConnectionDialog
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import isChecked [as 别名]
#.........这里部分代码省略.........
port = str(existing_kernel.get("port", 22))
is_ssh_kf = existing_kernel.get("is_ssh_keyfile", False)
ssh_kf = existing_kernel.get("ssh_key_file_path", "")
if connection_file_path != "":
self.cf.setText(connection_file_path)
if username != "":
self.un.setText(username)
if hostname != "":
self.hn.setText(hostname)
if ssh_kf != "":
self.kf.setText(ssh_kf)
self.rm_group.setChecked(is_remote)
self.pn.setText(port)
self.kf_radio.setChecked(is_ssh_kf)
self.pw_radio.setChecked(not is_ssh_kf)
try:
import keyring
ssh_passphrase = keyring.get_password("spyder_remote_kernel",
"ssh_key_passphrase")
ssh_password = keyring.get_password("spyder_remote_kernel",
"ssh_password")
if ssh_passphrase:
self.kfp.setText(ssh_passphrase)
if ssh_password:
self.pw.setText(ssh_password)
except Exception:
pass
def save_connection_settings(self):
"""Save user's kernel connection settings."""
if not self.save_layout.isChecked():
return
is_ssh_key = bool(self.kf_radio.isChecked())
connection_settings = {
"json_file_path": self.cf.text(),
"is_remote": self.rm_group.isChecked(),
"username": self.un.text(),
"hostname": self.hn.text(),
"port": self.pn.text(),
"is_ssh_keyfile": is_ssh_key,
"ssh_key_file_path": self.kf.text()
}
CONF.set("existing-kernel", "settings", connection_settings)
try:
import keyring
if is_ssh_key:
keyring.set_password("spyder_remote_kernel",
"ssh_key_passphrase",
self.kfp.text())
else:
keyring.set_password("spyder_remote_kernel",
"ssh_password",
self.pw.text())
except Exception:
pass
def select_connection_file(self):
cf = getopenfilename(self, _('Select kernel connection file'),
jupyter_runtime_dir(), '*.json;;*.*')[0]
self.cf.setText(cf)
示例12: ContourOptionsDialog
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import isChecked [as 别名]
#.........这里部分代码省略.........
self.contour_settings.options["vmin"] = vmin
else:
self.contour_settings.vmin = None
self.contour_settings.options["vmin"] = None
# Redraw contour
if self.contour_settings.image_viewer.is_contour_active:
self.contour_settings.draw_function()
self.close()
def preview(self):
"""
Prepare preview contour settings
and send to image viewer
"""
success = self.input_validation()
if not success:
return
image_viewer = self.contour_settings.image_viewer
preview_settings = ContourSettings(image_viewer)
preview_settings.dialog = self
preview_settings.options = self.contour_settings.options.copy()
preview_settings.spacing = self.contour_settings.spacing
# Change Color Map
self._colormap_index = self.colormap_combo.currentIndex()
colormap = self._colormap_members[self._colormap_index]
preview_settings.options["cmap"] = colormap
# labels
add_contour_label = self.contour_label_checkBox.isChecked()
preview_settings.add_contour_label = add_contour_label
# font size
if add_contour_label:
font_size = int(self.font_size_input.text())
preview_settings.font_size = font_size
# Spacing
if self.is_custom_spacing:
preview_settings.spacing = float(self.spacing_input.text())
else:
preview_settings.spacing = None
# vmax
if self.is_vmax:
vmax = float(self.vmax_input.text())
preview_settings.vmax = vmax
preview_settings.options["vmax"] = vmax
else:
preview_settings.vmax = None
preview_settings.options["vmax"] = None
# vmin
if self.is_vmin:
vmin = float(self.vmin_input.text())
preview_settings.vmin = vmin
preview_settings.options["vmin"] = vmin
else:
preview_settings.vmin = None
preview_settings.options["vmin"] = None
# Redraw contour