本文整理汇总了Python中qtpy.QtWidgets.QCheckBox.setChecked方法的典型用法代码示例。如果您正苦于以下问题:Python QCheckBox.setChecked方法的具体用法?Python QCheckBox.setChecked怎么用?Python QCheckBox.setChecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QCheckBox
的用法示例。
在下文中一共展示了QCheckBox.setChecked方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_and_check
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setChecked [as 别名]
def setup_and_check(self, data, title=''):
"""
Setup DataFrameEditor:
return False if data is not supported, True otherwise
"""
self.layout = QGridLayout()
self.setLayout(self.layout)
self.setWindowIcon(ima.icon('arredit'))
if title:
title = to_text_string(title) + " - %s" % data.__class__.__name__
else:
title = _("%s editor") % data.__class__.__name__
if isinstance(data, Series):
self.is_series = True
data = data.to_frame()
self.setWindowTitle(title)
self.resize(600, 500)
self.dataModel = DataFrameModel(data, parent=self)
self.dataTable = DataFrameView(self, self.dataModel)
self.layout.addWidget(self.dataTable)
self.setLayout(self.layout)
self.setMinimumSize(400, 300)
# Make the dialog act as a window
self.setWindowFlags(Qt.Window)
btn_layout = QHBoxLayout()
btn = QPushButton(_("Format"))
# disable format button for int type
btn_layout.addWidget(btn)
btn.clicked.connect(self.change_format)
btn = QPushButton(_('Resize'))
btn_layout.addWidget(btn)
btn.clicked.connect(self.resize_to_contents)
bgcolor = QCheckBox(_('Background color'))
bgcolor.setChecked(self.dataModel.bgcolor_enabled)
bgcolor.setEnabled(self.dataModel.bgcolor_enabled)
bgcolor.stateChanged.connect(self.change_bgcolor_enable)
btn_layout.addWidget(bgcolor)
self.bgcolor_global = QCheckBox(_('Column min/max'))
self.bgcolor_global.setChecked(self.dataModel.colum_avg_enabled)
self.bgcolor_global.setEnabled(not self.is_series and
self.dataModel.bgcolor_enabled)
self.bgcolor_global.stateChanged.connect(self.dataModel.colum_avg)
btn_layout.addWidget(self.bgcolor_global)
btn_layout.addStretch()
bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
bbox.accepted.connect(self.accept)
bbox.rejected.connect(self.reject)
btn_layout.addWidget(bbox)
self.layout.addLayout(btn_layout, 2, 0)
return True
示例2: FontLayout
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setChecked [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: _SaveDialog
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setChecked [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)
示例4: __init__
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setChecked [as 别名]
def __init__(self, parent, data, readonly=False,
xlabels=None, ylabels=None):
QWidget.__init__(self, parent)
self.data = data
self.old_data_shape = None
if len(self.data.shape) == 1:
self.old_data_shape = self.data.shape
self.data.shape = (self.data.shape[0], 1)
elif len(self.data.shape) == 0:
self.old_data_shape = self.data.shape
self.data.shape = (1, 1)
format = SUPPORTED_FORMATS.get(data.dtype.name, '%s')
self.model = ArrayModel(self.data, format=format, xlabels=xlabels,
ylabels=ylabels, readonly=readonly, parent=self)
self.view = ArrayView(self, self.model, data.dtype, data.shape)
btn_layout = QHBoxLayout()
btn_layout.setAlignment(Qt.AlignLeft)
btn = QPushButton(_( "Format"))
# disable format button for int type
btn.setEnabled(is_float(data.dtype))
btn_layout.addWidget(btn)
btn.clicked.connect(self.change_format)
btn = QPushButton(_( "Resize"))
btn_layout.addWidget(btn)
btn.clicked.connect(self.view.resize_to_contents)
bgcolor = QCheckBox(_( 'Background color'))
bgcolor.setChecked(self.model.bgcolor_enabled)
bgcolor.setEnabled(self.model.bgcolor_enabled)
bgcolor.stateChanged.connect(self.model.bgcolor)
btn_layout.addWidget(bgcolor)
layout = QVBoxLayout()
layout.addWidget(self.view)
layout.addLayout(btn_layout)
self.setLayout(layout)
示例5: set_check_box
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setChecked [as 别名]
def set_check_box(self, row, col, state):
""" function to add a new select checkbox to a cell in a table row
won't add a new checkbox if one already exists
"""
# Check input
assert isinstance(state, bool)
# Check if cellWidget exists
if self.cellWidget(row, col):
# existing: just set the value
self.cellWidget(row, col).setChecked(state)
else:
# case to add checkbox
checkbox = QCheckBox()
checkbox.setText('')
checkbox.setChecked(state)
# Adding a widget which will be inserted into the table cell
# then centering the checkbox within this widget which in turn,
# centers it within the table column :-)
self.setCellWidget(row, col, checkbox)
# END-IF-ELSE
return
示例6: MessageCheckBox
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setChecked [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)
示例7: LSPServerEditor
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setChecked [as 别名]
#.........这里部分代码省略.........
self.args_input = QLineEdit(self)
self.args_input.setToolTip(_('Additional arguments required to '
'start the server'))
self.args_input.setText(args)
conf_label = QLabel(_('LSP Server Configurations:'))
self.conf_input = CodeEditor(None)
self.conf_input.textChanged.connect(self.validate)
color_scheme = CONF.get('appearance', 'selected')
self.conf_input.setup_editor(
language='JSON',
color_scheme=color_scheme,
wrap=False,
edge_line=True,
highlight_current_line=True,
highlight_current_cell=True,
occurrence_highlighting=True,
auto_unindent=True,
font=get_font(),
filename='config.json')
self.conf_input.setToolTip(_('Additional LSP server configurations '
'set at runtime. JSON required'))
conf_text = '{}'
try:
conf_text = json.dumps(configurations, indent=4, sort_keys=True)
except Exception:
pass
self.conf_input.set_text(conf_text)
self.json_label = QLabel(self.JSON_VALID, self)
self.external_cb = QCheckBox(_('External server'), self)
self.external_cb.setToolTip(_('Check if the server runs '
'on a remote location'))
self.external_cb.setChecked(external)
self.external_cb.stateChanged.connect(self.set_local_options)
hlayout = QHBoxLayout()
general_vlayout = QVBoxLayout()
general_vlayout.addWidget(server_settings_description)
vlayout = QVBoxLayout()
lang_layout = QVBoxLayout()
lang_layout.addWidget(lang_label)
lang_layout.addWidget(self.lang_cb)
# layout2 = QHBoxLayout()
# layout2.addLayout(lang_layout)
lang_layout.addWidget(self.external_cb)
vlayout.addLayout(lang_layout)
host_layout = QVBoxLayout()
host_layout.addWidget(host_label)
host_layout.addWidget(self.host_input)
port_layout = QVBoxLayout()
port_layout.addWidget(port_label)
port_layout.addWidget(self.port_spinner)
conn_info_layout = QHBoxLayout()
conn_info_layout.addLayout(host_layout)
conn_info_layout.addLayout(port_layout)
vlayout.addLayout(conn_info_layout)
cmd_layout = QVBoxLayout()
cmd_layout.addWidget(cmd_label)
cmd_layout.addWidget(self.cmd_input)
示例8: SampleLogsView
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setChecked [as 别名]
class SampleLogsView(QSplitter):
"""Sample Logs View
This contains a table of the logs, a plot of the currently
selected logs, and the statistics of the selected log.
"""
def __init__(self, presenter, parent = None, name = '', isMD=False, noExp = 0):
super(SampleLogsView, self).__init__(parent)
self.presenter = presenter
self.setWindowTitle("{} sample logs".format(name))
self.setWindowFlags(Qt.Window)
# Create sample log table
self.table = QTableView()
self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
self.table.clicked.connect(self.presenter.clicked)
self.table.doubleClicked.connect(self.presenter.doubleClicked)
self.table.contextMenuEvent = self.tableMenu
self.addWidget(self.table)
frame_right = QFrame()
layout_right = QVBoxLayout()
#Add full_time and experimentinfo options
layout_options = QHBoxLayout()
if isMD:
layout_options.addWidget(QLabel("Experiment Info #"))
self.experimentInfo = QSpinBox()
self.experimentInfo.setMaximum(noExp-1)
self.experimentInfo.valueChanged.connect(self.presenter.changeExpInfo)
layout_options.addWidget(self.experimentInfo)
self.full_time = QCheckBox("Relative Time")
self.full_time.setChecked(True)
self.full_time.stateChanged.connect(self.presenter.plot_logs)
layout_options.addWidget(self.full_time)
layout_right.addLayout(layout_options)
# Sample log plot
self.fig = Figure()
self.canvas = FigureCanvas(self.fig)
self.canvas.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding)
self.canvas.mpl_connect('button_press_event', self.presenter.plot_clicked)
self.ax = self.fig.add_subplot(111, projection='mantid')
layout_right.addWidget(self.canvas)
# Sample stats
self.create_stats_widgets()
layout_stats = QFormLayout()
layout_stats.addRow('', QLabel("Log Statistics"))
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"""
#.........这里部分代码省略.........
示例9: CondaPackageActionDialog
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setChecked [as 别名]
class CondaPackageActionDialog(QDialog):
""" """
def __init__(self, parent, env, name, action, version, versions):
super(CondaPackageActionDialog, self).__init__(parent)
self._parent = parent
self._env = env
self._version_text = None
self._name = name
self._dependencies_dic = {}
self._conda_process = \
conda_api_q.CondaProcess(self, self._on_process_finished)
# widgets
self.label = QLabel(self)
self.combobox_version = QComboBox()
self.label_version = QLabel(self)
self.widget_version = None
self.table_dependencies = None
self.checkbox = QCheckBox(_('Install dependencies (recommended)'))
self.bbox = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel, Qt.Horizontal,
self)
self.button_ok = self.bbox.button(QDialogButtonBox.Ok)
self.button_cancel = self.bbox.button(QDialogButtonBox.Cancel)
self.button_cancel.setDefault(True)
self.button_cancel.setAutoDefault(True)
dialog_size = QSize(300, 90)
# helper variable values
action_title = {const.UPGRADE: _("Upgrade package"),
const.DOWNGRADE: _("Downgrade package"),
const.REMOVE: _("Remove package"),
const.INSTALL: _("Install package")}
# Versions might have duplicates from different builds
versions = sort_versions(list(set(versions)), reverse=True)
# FIXME: There is a bug, a package installed by anaconda has version
# astropy 0.4 and the linked list 0.4 but the available versions
# in the json file do not include 0.4 but 0.4rc1... so...
# temporal fix is to check if inside list otherwise show full list
if action == const.UPGRADE:
if version in versions:
index = versions.index(version)
versions = versions[:index]
else:
versions = versions
elif action == const.DOWNGRADE:
if version in versions:
index = versions.index(version)
versions = versions[index+1:]
else:
versions = versions
elif action == const.REMOVE:
versions = [version]
self.combobox_version.setEnabled(False)
if len(versions) == 1:
if action == const.REMOVE:
labeltext = _('Package version to remove:')
else:
labeltext = _('Package version available:')
self.label_version.setText(versions[0])
self.widget_version = self.label_version
else:
labeltext = _("Select package version:")
self.combobox_version.addItems(versions)
self.widget_version = self.combobox_version
self.label.setText(labeltext)
self.label_version.setAlignment(Qt.AlignLeft)
self.table_dependencies = QWidget(self)
self._layout = QGridLayout()
self._layout.addWidget(self.label, 0, 0, Qt.AlignVCenter |
Qt.AlignLeft)
self._layout.addWidget(self.widget_version, 0, 1, Qt.AlignVCenter |
Qt.AlignRight)
self.widgets = [self.checkbox, self.button_ok, self.widget_version,
self.table_dependencies]
row_index = 1
# Create a Table
if action in [const.INSTALL, const.UPGRADE, const.DOWNGRADE]:
table = QTableView(self)
dialog_size = QSize(dialog_size.width() + 40, 300)
self.table_dependencies = table
row_index = 1
self._layout.addItem(QSpacerItem(10, 5), row_index, 0)
self._layout.addWidget(self.checkbox, row_index + 1, 0, 1, 2)
self.checkbox.setChecked(True)
self._changed_version(versions[0])
table.setSelectionBehavior(QAbstractItemView.SelectRows)
table.verticalHeader().hide()
#.........这里部分代码省略.........
示例10: ImageRotationDialog
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setChecked [as 别名]
#.........这里部分代码省略.........
f = signal._plot.navigator_plot.update
else:
f = signal._plot.signal_plot.update
# TODO: TAG: Functionality check
if hasattr(signal, 'events') and hasattr(
signal.events, 'data_changed'):
if disconnect:
signal.events.data_changed.disconnect(f)
else:
signal.events.data_changed.connect(f, [])
self._connected_updates = not disconnect
def update(self):
angle = self.num_angle.value()
reshape = self.chk_reshape.isChecked()
if self.opt_new.isChecked():
if self.new_out is None:
out = None
else:
out = self.new_out.signal
elif self.opt_replace.isChecked():
out = self.signal.signal
else:
return # Indeterminate state, do nothing
s = self.plugin.rotate_signal(angle, self.signal.signal, record=False,
reshape=reshape, out=out, axes=self.axes)
if out is None:
s.metadata.General.title = self.signal.name + "[Rotated]"
s.plot()
self.connect_update_plot(s)
if (self.gbo_preview.isChecked() and self.opt_new.isChecked() and
self.new_out is None):
self.new_out = self.ui.lut_signalwrapper[s]
else:
s = out
if self.chk_grid.isChecked() is True:
pass # TODO: Draw grid
def create_controls(self):
"""
Create UI controls.
"""
vbox = QVBoxLayout()
form = QFormLayout()
self.num_angle = QDoubleSpinBox()
self.num_angle.setValue(0.0)
self.num_angle.setMinimum(-360)
self.num_angle.setMaximum(360)
form.addRow(tr("Angle:"), self.num_angle)
vbox.addLayout(form)
self.gbo_preview = QGroupBox(tr("Preview"))
self.gbo_preview.setCheckable(True)
self.gbo_preview.setChecked(False)
gbo_vbox = QVBoxLayout()
self.chk_grid = QCheckBox(tr("Grid"))
self.chk_grid.setChecked(False)
self.num_grid = QSpinBox()
self.num_grid.setValue(4)
self.num_grid.setMinimum(1)
self.num_grid.setEnabled(False)
self.chk_grid.toggled[bool].connect(self.num_grid.setEnabled)
gbo_vbox.addWidget(self.chk_grid)
gbo_vbox.addWidget(self.num_grid)
self.gbo_preview.setLayout(gbo_vbox)
vbox.addWidget(self.gbo_preview)
self.gbo_preview.toggled[bool].connect(self.set_preview)
self.gbo_output = QGroupBox(tr("Output"))
self.opt_new = QRadioButton(tr("New signal"))
self.opt_replace = QRadioButton(tr("In place"))
self.opt_new.setChecked(True)
gbo_vbox2 = QVBoxLayout()
gbo_vbox2.addWidget(self.opt_new)
gbo_vbox2.addWidget(self.opt_replace)
self.gbo_output.setLayout(gbo_vbox2)
vbox.addWidget(self.gbo_output)
self.chk_reshape = QCheckBox(tr("Resize to fit"))
self.chk_reshape.setChecked(False)
vbox.addWidget(self.chk_reshape)
self.btn_ok = QPushButton(tr("&OK"))
self.btn_ok.setDefault(True)
self.btn_ok.clicked.connect(self.accept)
self.btn_cancel = QPushButton(tr("&Cancel"))
self.btn_cancel.clicked.connect(self.reject)
hbox = QHBoxLayout()
hbox.addWidget(self.btn_ok)
hbox.addWidget(self.btn_cancel)
vbox.addLayout(hbox)
vbox.addStretch(1)
self.setLayout(vbox)
示例11: ColorbarWidget
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setChecked [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():
#.........这里部分代码省略.........
示例12: DataFrameEditor
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setChecked [as 别名]
class DataFrameEditor(QDialog):
"""
Dialog for displaying and editing DataFrame and related objects.
Signals
-------
sig_option_changed(str, object): Raised if an option is changed.
Arguments are name of option and its new value.
"""
sig_option_changed = Signal(str, object)
def __init__(self, parent=None):
QDialog.__init__(self, parent)
# Destroying the C++ object right after closing the dialog box,
# otherwise it may be garbage-collected in another QThread
# (e.g. the editor's analysis thread in Spyder), thus leading to
# a segmentation fault on UNIX or an application crash on Windows
self.setAttribute(Qt.WA_DeleteOnClose)
self.is_series = False
self.layout = None
def setup_and_check(self, data, title=''):
"""
Setup DataFrameEditor:
return False if data is not supported, True otherwise.
Supported types for data are DataFrame, Series and Index.
"""
self.layout = QGridLayout()
self.setLayout(self.layout)
self.setWindowIcon(ima.icon('arredit'))
if title:
title = to_text_string(title) + " - %s" % data.__class__.__name__
else:
title = _("%s editor") % data.__class__.__name__
if isinstance(data, Series):
self.is_series = True
data = data.to_frame()
elif isinstance(data, Index):
data = DataFrame(data)
self.setWindowTitle(title)
self.resize(600, 500)
self.dataModel = DataFrameModel(data, parent=self)
self.dataTable = DataFrameView(self, self.dataModel)
self.layout.addWidget(self.dataTable)
self.setLayout(self.layout)
self.setMinimumSize(400, 300)
# Make the dialog act as a window
self.setWindowFlags(Qt.Window)
btn_layout = QHBoxLayout()
btn = QPushButton(_("Format"))
# disable format button for int type
btn_layout.addWidget(btn)
btn.clicked.connect(self.change_format)
btn = QPushButton(_('Resize'))
btn_layout.addWidget(btn)
btn.clicked.connect(self.resize_to_contents)
bgcolor = QCheckBox(_('Background color'))
bgcolor.setChecked(self.dataModel.bgcolor_enabled)
bgcolor.setEnabled(self.dataModel.bgcolor_enabled)
bgcolor.stateChanged.connect(self.change_bgcolor_enable)
btn_layout.addWidget(bgcolor)
self.bgcolor_global = QCheckBox(_('Column min/max'))
self.bgcolor_global.setChecked(self.dataModel.colum_avg_enabled)
self.bgcolor_global.setEnabled(not self.is_series and
self.dataModel.bgcolor_enabled)
self.bgcolor_global.stateChanged.connect(self.dataModel.colum_avg)
btn_layout.addWidget(self.bgcolor_global)
btn_layout.addStretch()
bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
bbox.accepted.connect(self.accept)
bbox.rejected.connect(self.reject)
btn_layout.addWidget(bbox)
self.layout.addLayout(btn_layout, 2, 0)
return True
def change_bgcolor_enable(self, state):
"""
This is implementet so column min/max is only active when bgcolor is
"""
self.dataModel.bgcolor(state)
self.bgcolor_global.setEnabled(not self.is_series and state > 0)
def change_format(self):
"""
Ask user for display format for floats and use it.
This function also checks whether the format is valid and emits
`sig_option_changed`.
"""
format, valid = QInputDialog.getText(self, _('Format'),
_("Float formatting"),
#.........这里部分代码省略.........
示例13: ItemPropertyDialog
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setChecked [as 别名]
class ItemPropertyDialog(QDialog):
def __init__(self, jsonitem: JsonItem, parent=None):
super().__init__(parent)
assert jsonitem is not None
self.item = jsonitem
# name
self.nameLabel = QLabel(self.tr("name:"))
self.nameLineEdit = QLineEdit(self.item.name or "")
self.nameLabel.setBuddy(self.nameLineEdit)
# unit
self.unitLabel = QLabel(self.tr("unit:"))
self.unitLineEdit = QLineEdit(self.item.unit or "")
self.unitLabel.setBuddy(self.unitLineEdit)
# type
self.typeLabel = QLabel(self.tr("type:"))
self.typeComboBox = QComboBox()
self.typeComboBox.addItems([k for k, t in VALUETYPES])
self.typeComboBox.setCurrentIndex(
self.typeComboBox.findText(self.item.type))
self.typeComboBox.currentIndexChanged.connect(self.data_changed)
self.typeLabel.setBuddy(self.typeComboBox)
# decimals
self.decimalsLabel = QLabel(self.tr("decimals:"))
self.decimalsSpinBox = QSpinBox()
self.decimalsSpinBox.setRange(0, 10)
self.decimalsSpinBox.setValue(self.item.decimals or 0)
self.decimalsLabel.setBuddy(self.decimalsSpinBox)
self.decimalsSpinBox.valueChanged.connect(self.data_changed)
self.last_decimals = self.decimalsSpinBox.value()
# min
self.minLabel = QLabel(self.tr("minimum:"))
self.minSpinBox =QDoubleSpinBox()
self.minSpinBox.setRange(-sys.maxsize, sys.maxsize)
self.minLabel.setBuddy(self.minSpinBox)
self.minSpinBox.setValue(self.item.min or 0.0)
# max
self.maxLabel = QLabel(self.tr("maximum:"))
self.maxSpinBox = QDoubleSpinBox()
self.maxSpinBox.setRange(-sys.maxsize, sys.maxsize)
self.maxSpinBox.setValue(self.item.max or 100.0)
# numerator
self.scalefactorLabel = QLabel(self.tr("scalefactor:"))
self.scalefactorSpinBox = NoZerosDoubleSpinBox()
self.scalefactorSpinBox.setRange(-sys.maxsize, sys.maxsize)
self.scalefactorSpinBox.setButtonSymbols(QSpinBox.NoButtons)
self.scalefactorSpinBox.setDecimals(10)
self.scalefactorSpinBox.setValue(self.item.scalefactor or 1)
self.scalefactorLabel.setBuddy(self.scalefactorSpinBox)
# readonly
self.readonlyCheckBox = QCheckBox(self.tr("readonly"))
self.readonlyCheckBox.setChecked(Qt.Checked if self.item.readonly
else Qt.Unchecked)
self.readonlyCheckBox.stateChanged.connect(self.data_changed)
# buttons
self.buttons = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
Qt.Horizontal
)
self.buttons.accepted.connect(self.accept)
self.buttons.rejected.connect(self.reject)
# layout
layout = QGridLayout()
layout.addWidget(self.nameLabel, 0, 0)
layout.addWidget(self.nameLineEdit, 0, 1)
layout.addWidget(self.unitLabel, 1, 0)
layout.addWidget(self.unitLineEdit, 1, 1)
layout.addWidget(self.typeLabel, 2, 0)
layout.addWidget(self.typeComboBox, 2, 1)
layout.addWidget(self.decimalsLabel, 3, 0)
layout.addWidget(self.decimalsSpinBox, 3, 1)
layout.addWidget(self.minLabel, 4, 0)
layout.addWidget(self.minSpinBox, 4, 1)
layout.addWidget(self.maxLabel, 5, 0)
layout.addWidget(self.maxSpinBox, 5, 1)
layout.addWidget(self.scalefactorLabel, 6, 0)
layout.addWidget(self.scalefactorSpinBox, 6, 1)
layout.addWidget(self.readonlyCheckBox, 7, 0, 1, 2)
layout.addWidget(self.buttons, 8, 0, 1, 2)
self.setLayout(layout)
# misc
self.setWindowTitle("Edit JsonItem '%s'" % self.item.key)
self.data_changed()
def accept(self):
self.item.name = self.nameLineEdit.text()
self.item.unit = self.unitLineEdit.text()
self.item.decimals = self.decimalsSpinBox.value()
self.item.min = self.minSpinBox.value()
#.........这里部分代码省略.........
示例14: ContourOptionsDialog
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setChecked [as 别名]
class ContourOptionsDialog(QDialog):
"""
Dialog box for selecting contour options
"""
def __init__(self, contour_settings):
super(ContourOptionsDialog, self).__init__(contour_settings.cubeviz_layout)
self.setWindowFlags(self.windowFlags() | Qt.Tool)
self.setWindowTitle("Contour Options")
self.is_preview_active = False # preview mode?
self.contour_settings = contour_settings # ref to caller ContourSettings
self.image_viewer = self.contour_settings.image_viewer # ref to image viewer
self.options = self.contour_settings.options # ref to ContourSettings options
self._colormap_members = self.contour_settings.colormap_members # Colormap options
self._colormap_index = DEFAULT_GLUE_COLORMAP_INDEX # Currently selected colormap
if "cmap" in self.options:
if self.options["cmap"] in self._colormap_members:
self._colormap_index = self._colormap_members.index(self.options["cmap"])
# Is there a user spacing?
if self.contour_settings.spacing is None:
self.is_custom_spacing = False
else:
self.is_custom_spacing = True
# Is there a user min?
if self.contour_settings.vmin is None:
self.is_vmin = False
else:
self.is_vmin = True
# Is there a user max?
if self.contour_settings.vmax is None:
self.is_vmax = False
else:
self.is_vmax = True
self.add_contour_label = self.contour_settings.add_contour_label # bool
self._init_ui()
def _init_ui(self):
# Line 1: Color map
self.colormap_label = QLabel("Color Scheme: ")
self.colormap_combo = QColormapCombo()
self.colormap_combo.addItem("", userData=UserDataWrapper(cm.viridis))
self.colormap_combo._update_icons()
self.colormap_combo.setCurrentIndex(self._colormap_index)
self.colormap_combo.setMaximumWidth(150)
self.colormap_combo.currentIndexChanged.connect(
self._on_colormap_change)
# hbl is short for Horizontal Box Layout
hbl1 = QHBoxLayout()
hbl1.addWidget(self.colormap_label)
hbl1.addWidget(self.colormap_combo)
# Line 2: Display contour labels
self.contour_label_checkBox = QCheckBox("Contour labels (font size):")
if self.contour_settings.add_contour_label:
self.contour_label_checkBox.setChecked(True)
self.contour_label_checkBox.toggled.connect(self.toggle_labels)
font_string = str(self.contour_settings.font_size)
self.font_size_input = QLineEdit(font_string)
self.font_size_input.setFixedWidth(150)
self.font_size_input.setDisabled(
not self.contour_settings.add_contour_label)
hbl2 = QHBoxLayout()
hbl2.addWidget(self.contour_label_checkBox)
hbl2.addWidget(self.font_size_input)
# Line 3: Contour Spacing
self.custom_spacing_checkBox = QCheckBox("Contour spacing (interval):")
if self.is_custom_spacing:
self.custom_spacing_checkBox.setChecked(True)
self.custom_spacing_checkBox.toggled.connect(self.custom_spacing)
self.spacing_input = QLineEdit()
self.spacing_input.setFixedWidth(150)
self.spacing_input.setDisabled(not self.is_custom_spacing)
spacing = ""
if self.is_custom_spacing:
spacing = str(self.contour_settings.spacing)
elif self.contour_settings.data_spacing is not None:
spacing = self.contour_settings.data_spacing
spacing = "{0:1.4f}".format(spacing)
self.spacing_default_text = spacing
self.spacing_input.setText(spacing)
hbl3 = QHBoxLayout()
hbl3.addWidget(self.custom_spacing_checkBox)
hbl3.addWidget(self.spacing_input)
# Line 4: Vmax
self.vmax_checkBox = QCheckBox("Set max:")
#.........这里部分代码省略.........
示例15: populate_gui
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setChecked [as 别名]
def populate_gui(self):
_contain_parsed = self.contain_parsed
for _row, _entry in enumerate(_contain_parsed):
if _entry == ['']:
continue
self.parent.ui.table.insertRow(_row)
# select
_layout = QHBoxLayout()
_widget = QCheckBox()
_widget.setEnabled(True)
_layout.addWidget(_widget)
_layout.addStretch()
_new_widget = QWidget()
_new_widget.setLayout(_layout)
_widget.stateChanged.connect(lambda state=0, row=_row:
self.parent.table_select_state_changed(state, row))
self.parent.ui.table.setCellWidget(_row, 0, _new_widget)
# name
_item = QTableWidgetItem(_entry[1])
self.parent.ui.table.setItem(_row, 1, _item)
# runs
_item = QTableWidgetItem(_entry[2])
self.parent.ui.table.setItem(_row, 2, _item)
# Sample formula
if _entry[3]:
_item = QTableWidgetItem(_entry[3])
else:
_item = QTableWidgetItem("")
self.parent.ui.table.setItem(_row, 3, _item)
# mass density
if _entry[4]:
_item = QTableWidgetItem(_entry[4])
else:
_item = QTableWidgetItem("")
self.parent.ui.table.setItem(_row, 4, _item)
# radius
if _entry[5]:
_item = QTableWidgetItem(_entry[5])
else:
_item = QTableWidgetItem("")
self.parent.ui.table.setItem(_row, 5, _item)
# packing fraction
if _entry[6]:
_item = QTableWidgetItem(_entry[6])
else:
_item = QTableWidgetItem("")
self.parent.ui.table.setItem(_row, 6, _item)
# sample shape
_widget = QComboBox()
_widget.addItem("cylindrical")
_widget.addItem("spherical")
if _entry[7] == "spherical":
_widget.setCurrentIndex(1)
self.parent.ui.table.setCellWidget(_row, 7, _widget)
# do abs corr
_layout = QHBoxLayout()
_widget = QCheckBox()
if _entry[8] == "True":
_widget.setCheckState(Qt.Checked)
_widget.setStyleSheet("border: 2px; solid-black")
_widget.setEnabled(True)
_layout.addStretch()
_layout.addWidget(_widget)
_layout.addStretch()
_new_widget = QWidget()
_new_widget.setLayout(_layout)
self.parent.ui.table.setCellWidget(_row, 8, _new_widget)
for _row, _entry in enumerate(_contain_parsed):
if _entry == ['']:
continue
# select
_widget = self.parent.ui.table.cellWidget(_row, 0).children()[1]
if _entry[0] == "True":
_widget.setChecked(True)