def read_settings(self):
settings = QtCore.QSettings(self._application, self._section)
for key in settings.allKeys():
value = settings.value(key)
try:
# This is required to skip the tab_position key/value
this = getattr(self.ui, key)
except:
continue
if isinstance(this, QW.QLineEdit):
this.setText(value)
elif isinstance(this, QW.QSpinBox):
this.setValue(int(value))
elif isinstance(this, QW.QCheckBox):
if value in ['false', False, "False"]:
this.setChecked(False)
else:
this.setChecked(True)
elif isinstance(this, FileBrowser):
this.set_filenames(value)
else:
print('could not handle : %s' % this)
# The last tab position
self._tab_pos = settings.value("tab_position", 0, type=int)
self.ui.tabs.setCurrentIndex(self._tab_pos)
python类QSpinBox()的实例源码
def get_settings(self):
# get all items to save in settings
items = {}
names = self._get_widget_names()
for name in names:
widget = getattr(self.ui, name)
if isinstance(widget, QW.QLineEdit):
value = widget.text()
elif isinstance(widget, QW.QSpinBox):
value = widget.value()
elif isinstance(widget, QW.QCheckBox):
value = widget.isChecked()
elif isinstance(widget, QW.QSpinBox):
value = widget.value()
elif isinstance(widget, FileBrowser):
value = widget.get_filenames()
else:
raise NotImplementedError("for developers")
items[name] = value
items["tab_position"] = self.ui.tabs.currentIndex()
return items
def _get_value(self):
"""Return a string"""
if isinstance(self.widget, QW.QSpinBox):
value = self.widget.text()
elif isinstance(self.widget, QW.QLabel):
value = self.widget.text()
elif isinstance(self.widget, FileBrowser):
if self.widget.path_is_setup() is False:
value = ""
else:
value = self.widget.get_filenames()
else:
try:
value = self.widget.text()
except:
print("unknown widget" + str(type(self.widget)))
value = ""
return value
def __init__(self, text, unit = None, minimum = None, maximum = None, parent = None):
"""
Initialization of the CfgSpinBox class (used for int values).
@param text: text string associated with the SpinBox
@param minimum: min value (int)
@param minimum: max value (int)
"""
QWidget.__init__(self, parent)
self.spinbox = QSpinBox(parent)
if unit is not None:
self.setUnit(unit)
self.setSpec({'minimum': minimum, 'maximum': maximum, 'comment': ''})
self.label = QLabel(text, parent)
self.layout = QHBoxLayout(parent);
self.spinbox.setMinimumWidth(200) #Provide better alignment with other items
self.layout.addWidget(self.label)
self.layout.addStretch()
self.layout.addWidget(self.spinbox)
self.setLayout(self.layout)
def __init__(self,x_min,x_max,data):
QWidget.__init__(self)
self.setWindowTitle(_("Poly fit")+"(https://www.gpvdm.com)")
self.data=data
self.ret_math=None
self.ret=None
self.interal_data=[]
for i in range (0,self.data.y_len): #x_nm= [x * 1e9 for x in self.data.y_scale]
x=self.data.y_scale[i]
#print(x_min,x,x_max)
if x>=x_min and x<=x_max:
self.interal_data.append((self.data.y_scale[i],self.data.data[0][0][i]))
#print(self.data.y_scale[i],self.data.data[0][0][i])
#frequency, = self.ax1.plot(x_nm,self.data.data[0][0][i], 'bo-', linewidth=3 ,alpha=1.0)
#print(self.interal_data)
self.main_vbox=QVBoxLayout()
self.label = QLabel(_("Polynomial coefficients"))
self.main_vbox.addWidget(self.label)
self.sp = QSpinBox()
self.main_vbox.addWidget(self.sp)
self.button = QPushButton(_("Ok"), self)
self.button.clicked.connect(self.callback_click_ok)
self.main_vbox.addWidget(self.button)
self.setLayout(self.main_vbox)
ret=False
def __init__(self, mainWindow, staticExportItem):
super().__init__(mainWindow, "")
self.mainWindow = mainWindow
self.staticExportItem = staticExportItem
self.layout.insertRow(0, QtWidgets.QLabel("edit block #{}".format(staticExportItem["id"])))
self.name = QtWidgets.QLineEdit(self.staticExportItem["name"])
self.name.selectAll()
self.layout.addRow("name", self.name)
#self.minimumInTicks = QtWidgets.QSpinBox()
self.minimumInTicks = CombinedTickWidget()
self.minimumInTicks.setValue(self.staticExportItem["minimumInTicks"])
self.layout.addRow("minimum in ticks", self.minimumInTicks)
self.__call__()
def __init__(self, mainWindow):
super().__init__(mainWindow, "Instrument Change")
self.program = QtWidgets.QSpinBox()
self.program.setValue(type(self).lastProgramValue)
self.msb = QtWidgets.QSpinBox()
self.msb.setValue(type(self).lastMsbValue)
self.lsb = QtWidgets.QSpinBox()
self.lsb.setValue(type(self).lastLsbValue)
self.instrumentName = QtWidgets.QLineEdit()
self.shortInstrumentName = QtWidgets.QLineEdit()
for label, spinbox in (("Program", self.program), ("Bank MSB", self.msb), ("Bank LSB", self.lsb)):
spinbox.setMinimum(0)
spinbox.setMaximum(127)
spinbox.setSingleStep(1)
self.layout.addRow(label, spinbox)
self.layout.addRow("Instr.Name", self.instrumentName)
self.layout.addRow("Short Name", self.shortInstrumentName)
self.insert = QtWidgets.QPushButton("Insert")
self.insert.clicked.connect(self.process)
self.layout.addWidget(self.insert)
def __init__(self, parent):
super().__init__('Margins', parent)
self.margin_left_edit = QtWidgets.QSpinBox(
self, minimum=0, maximum=999)
self.margin_right_edit = QtWidgets.QSpinBox(
self, minimum=0, maximum=999)
self.margin_vertical_edit = QtWidgets.QSpinBox(
self, minimum=0, maximum=999)
layout = QtWidgets.QGridLayout(self)
layout.setColumnStretch(0, 1)
layout.setColumnStretch(1, 2)
layout.addWidget(QtWidgets.QLabel('Left:', self), 0, 0)
layout.addWidget(self.margin_left_edit, 0, 1)
layout.addWidget(QtWidgets.QLabel('Right:', self), 1, 0)
layout.addWidget(self.margin_right_edit, 1, 1)
layout.addWidget(QtWidgets.QLabel('Vertical:', self), 2, 0)
layout.addWidget(self.margin_vertical_edit, 2, 1)
dimred_FastICA.py 文件源码
项目:PySAT_Point_Spectra_GUI
作者: USGS-Astrogeology
项目源码
文件源码
阅读 19
收藏 0
点赞 0
评论 0
def setupUi(self, Form):
Form.setObjectName("Form")
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth())
Form.setSizePolicy(sizePolicy)
self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setObjectName("verticalLayout")
self.groupBox = QtWidgets.QGroupBox(Form)
self.groupBox.setObjectName("groupBox")
self.formLayout = QtWidgets.QFormLayout(self.groupBox)
self.formLayout.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
self.formLayout.setObjectName("formLayout")
self.nc_label = QtWidgets.QLabel(self.groupBox)
self.nc_label.setObjectName("nc_label")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.nc_label)
self.nc_spin = QtWidgets.QSpinBox(self.groupBox)
self.nc_spin.setObjectName("nc_spin")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.nc_spin)
self.verticalLayout.addWidget(self.groupBox)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self, Form):
Form.setObjectName("Form")
self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setObjectName("verticalLayout")
self.groupbox = QtWidgets.QGroupBox(Form)
self.groupbox.setObjectName("groupbox")
self.formLayout_2 = QtWidgets.QFormLayout(self.groupbox)
self.formLayout_2.setObjectName("formLayout_2")
self.halfWindowLabel = QtWidgets.QLabel(self.groupbox)
self.halfWindowLabel.setObjectName("halfWindowLabel")
self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.halfWindowLabel)
self.halfWindowSpinBox = QtWidgets.QSpinBox(self.groupbox)
self.halfWindowSpinBox.setObjectName("halfWindowSpinBox")
self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.halfWindowSpinBox)
self.numOfErosionsLabel = QtWidgets.QLabel(self.groupbox)
self.numOfErosionsLabel.setObjectName("numOfErosionsLabel")
self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.numOfErosionsLabel)
self.numOfErosionsSpinBox = QtWidgets.QSpinBox(self.groupbox)
self.numOfErosionsSpinBox.setObjectName("numOfErosionsSpinBox")
self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.numOfErosionsSpinBox)
self.verticalLayout.addWidget(self.groupbox)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self, Form):
Form.setObjectName("Form")
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth())
Form.setSizePolicy(sizePolicy)
self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setObjectName("verticalLayout")
self.groupBox = QtWidgets.QGroupBox(Form)
self.groupBox.setObjectName("groupBox")
self.formLayout = QtWidgets.QFormLayout(self.groupBox)
self.formLayout.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
self.formLayout.setObjectName("formLayout")
self.nc_label = QtWidgets.QLabel(self.groupBox)
self.nc_label.setObjectName("nc_label")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.nc_label)
self.nc_spin = QtWidgets.QSpinBox(self.groupBox)
self.nc_spin.setObjectName("nc_spin")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.nc_spin)
self.verticalLayout.addWidget(self.groupBox)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self, Form):
Form.setObjectName("Form")
self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setObjectName("verticalLayout")
self.groupbox = QtWidgets.QGroupBox(Form)
self.groupbox.setObjectName("groupbox")
self.formLayout_2 = QtWidgets.QFormLayout(self.groupbox)
self.formLayout_2.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
self.formLayout_2.setObjectName("formLayout_2")
self.windowSizeLabel = QtWidgets.QLabel(self.groupbox)
self.windowSizeLabel.setObjectName("windowSizeLabel")
self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.windowSizeLabel)
self.windowSizeSpinBox = QtWidgets.QSpinBox(self.groupbox)
self.windowSizeSpinBox.setObjectName("windowSizeSpinBox")
self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.windowSizeSpinBox)
self.numOfRangesLabel = QtWidgets.QLabel(self.groupbox)
self.numOfRangesLabel.setObjectName("numOfRangesLabel")
self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.numOfRangesLabel)
self.numOfRangesSpinBox = QtWidgets.QSpinBox(self.groupbox)
self.numOfRangesSpinBox.setObjectName("numOfRangesSpinBox")
self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.numOfRangesSpinBox)
self.verticalLayout.addWidget(self.groupbox)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self, Form):
Form.setObjectName("Form")
self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setObjectName("verticalLayout")
self.groupbox = QtWidgets.QGroupBox(Form)
self.groupbox.setObjectName("groupbox")
self.formLayout_2 = QtWidgets.QFormLayout(self.groupbox)
self.formLayout_2.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
self.formLayout_2.setObjectName("formLayout_2")
self.smoothnessLabel = QtWidgets.QLabel(self.groupbox)
self.smoothnessLabel.setObjectName("smoothnessLabel")
self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.smoothnessLabel)
self.smoothnessDoubleSpinBox = QtWidgets.QDoubleSpinBox(self.groupbox)
self.smoothnessDoubleSpinBox.setObjectName("smoothnessDoubleSpinBox")
self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.smoothnessDoubleSpinBox)
self.dilationLabel = QtWidgets.QLabel(self.groupbox)
self.dilationLabel.setObjectName("dilationLabel")
self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.dilationLabel)
self.dilationSpinBox = QtWidgets.QSpinBox(self.groupbox)
self.dilationSpinBox.setObjectName("dilationSpinBox")
self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.dilationSpinBox)
self.verticalLayout.addWidget(self.groupbox)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self, Form):
Form.setObjectName("Form")
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth())
Form.setSizePolicy(sizePolicy)
self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setObjectName("verticalLayout")
self.groupBox = QtWidgets.QGroupBox(Form)
self.groupBox.setObjectName("groupBox")
self.formLayout = QtWidgets.QFormLayout(self.groupBox)
self.formLayout.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
self.formLayout.setObjectName("formLayout")
self.nc_label = QtWidgets.QLabel(self.groupBox)
self.nc_label.setObjectName("nc_label")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.nc_label)
self.nc_spin = QtWidgets.QSpinBox(self.groupBox)
self.nc_spin.setObjectName("nc_spin")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.nc_spin)
self.verticalLayout.addWidget(self.groupBox)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def setupUi(self, Form):
Form.setObjectName("Form")
self.verticalLayout = QtWidgets.QVBoxLayout(Form)
self.verticalLayout.setObjectName("verticalLayout")
self.groupbox = QtWidgets.QGroupBox(Form)
self.groupbox.setObjectName("groupbox")
self.formLayout_2 = QtWidgets.QFormLayout(self.groupbox)
self.formLayout_2.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
self.formLayout_2.setObjectName("formLayout_2")
self.windowSizeLabel = QtWidgets.QLabel(self.groupbox)
self.windowSizeLabel.setObjectName("windowSizeLabel")
self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.windowSizeLabel)
self.windowSizeSpinBox = QtWidgets.QSpinBox(self.groupbox)
self.windowSizeSpinBox.setObjectName("windowSizeSpinBox")
self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.windowSizeSpinBox)
self.verticalLayout.addWidget(self.groupbox)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def saveSettings(self):
lineEdit_filemaskregex = self.findChild(QLineEdit, "lineEdit_filemaskregex")
cfg.settings.setValue('Options/FilemaskRegEx', lineEdit_filemaskregex.text())
lineEdit_mediainfo_path = self.findChild(QLineEdit, "lineEdit_mediainfo_path")
cfg.settings.setValue('Paths/mediainfo_bin', lineEdit_mediainfo_path.text())
lineEdit_mp3guessenc_path = self.findChild(QLineEdit, "lineEdit_mp3guessenc_path")
cfg.settings.setValue('Paths/mp3guessenc_bin', lineEdit_mp3guessenc_path.text())
lineEdit_aucdtect_path = self.findChild(QLineEdit, "lineEdit_aucdtect_path")
cfg.settings.setValue('Paths/aucdtect_bin', lineEdit_aucdtect_path.text())
lineEdit_sox_path = self.findChild(QLineEdit, "lineEdit_sox_path")
cfg.settings.setValue('Paths/sox_bin', lineEdit_sox_path.text())
lineEdit_ffprobe_path = self.findChild(QLineEdit, "lineEdit_ffprobe_path")
cfg.settings.setValue('Paths/ffprobe_bin', lineEdit_ffprobe_path.text())
checkBox_recursive = self.findChild(QCheckBox, "checkBox_recursive")
cfg.settings.setValue('Options/RecurseDirectories', checkBox_recursive.isChecked())
checkBox_followsymlinks = self.findChild(QCheckBox, "checkBox_followsymlinks")
cfg.settings.setValue('Options/FollowSymlinks', checkBox_followsymlinks.isChecked())
checkBox_cache = self.findChild(QCheckBox, "checkBox_cache")
cfg.settings.setValue('Options/UseCache', checkBox_cache.isChecked())
checkBox_cacheraw = self.findChild(QCheckBox, "checkBox_cacheraw")
cfg.settings.setValue('Options/CacheRawOutput', checkBox_cacheraw.isChecked())
spinBox_processes = self.findChild(QSpinBox, "spinBox_processes")
cfg.settings.setValue('Options/Processes', spinBox_processes.value())
spinBox_spectrogram_palette = self.findChild(QSpinBox, "spinBox_spectrogram_palette")
cfg.settings.setValue('Options/SpectrogramPalette', spinBox_spectrogram_palette.value())
checkBox_debug = self.findChild(QCheckBox, "checkBox_debug")
cfg.settings.setValue('Options/Debug', checkBox_debug.isChecked())
cfg.debug_enabled = checkBox_debug.isChecked()
checkBox_savewindowstate = self.findChild(QCheckBox, "checkBox_savewindowstate")
cfg.settings.setValue('Options/SaveWindowState', checkBox_savewindowstate.isChecked())
checkBox_clearfilelist = self.findChild(QCheckBox, "checkBox_clearfilelist")
cfg.settings.setValue('Options/ClearFilelist', checkBox_clearfilelist.isChecked())
checkBox_spectrogram = self.findChild(QCheckBox, "checkBox_spectrogram")
cfg.settings.setValue('Options/EnableSpectrogram', checkBox_spectrogram.isChecked())
checkBox_bitrate_graph = self.findChild(QCheckBox, "checkBox_bitrate_graph")
cfg.settings.setValue('Options/EnableBitGraph', checkBox_bitrate_graph.isChecked())
checkBox_aucdtect_scan = self.findChild(QCheckBox, "checkBox_aucdtect_scan")
cfg.settings.setValue('Options/auCDtect_scan', checkBox_aucdtect_scan.isChecked())
horizontalSlider_aucdtect_mode = self.findChild(QSlider, "horizontalSlider_aucdtect_mode")
cfg.settings.setValue('Options/auCDtect_mode', horizontalSlider_aucdtect_mode.value())
self.close()
def __init__(self, parent, node):
super(LocalNodeWidget, self).__init__(parent)
self.setTitle('Local node properties')
self._node = node
self._node_id_collector = uavcan.app.message_collector.MessageCollector(
self._node, uavcan.protocol.NodeStatus, timeout=uavcan.protocol.NodeStatus().OFFLINE_TIMEOUT_MS * 1e-3)
self._node_id_label = QLabel('Set local node ID:', self)
self._node_id_spinbox = QSpinBox(self)
self._node_id_spinbox.setMaximum(NODE_ID_MAX)
self._node_id_spinbox.setMinimum(NODE_ID_MIN)
self._node_id_spinbox.setValue(NODE_ID_MAX)
self._node_id_spinbox.valueChanged.connect(self._update)
self._node_id_apply = make_icon_button('check', 'Apply local node ID', self,
on_clicked=self._on_node_id_apply_clicked)
self._update_timer = QTimer(self)
self._update_timer.setSingleShot(False)
self._update_timer.timeout.connect(self._update)
self._update_timer.start(500)
self._update()
layout = QHBoxLayout(self)
layout.addWidget(self._node_id_label)
layout.addWidget(self._node_id_spinbox)
layout.addWidget(self._node_id_apply)
layout.addStretch(1)
self.setLayout(layout)
flash(self, 'Some functions will be unavailable unless local node ID is set')
def __init__( self, app ):
super().__init__( app, T_('Commit Log History') )
if self.app is None:
self.prefs = None
else:
self.prefs = self.app.prefs.log_history
self.default_limit = QtWidgets.QSpinBox()
self.default_limit.setRange( 1, 100000 )
self.default_limit.setSuffix( T_(' Commits') )
self.use_default_limit = QtWidgets.QCheckBox( T_('Use limit') )
self.default_until = QtWidgets.QSpinBox()
self.default_until.setRange( 1, 365 )
self.default_until.setSuffix( T_(' days') )
self.use_default_until = QtWidgets.QCheckBox( T_('Use until') )
self.default_since = QtWidgets.QSpinBox()
self.default_since.setRange( 2, 365 )
self.default_since.setSuffix( T_(' days') )
self.use_default_since = QtWidgets.QCheckBox( T_('Use since') )
if self.prefs is not None:
self.default_limit.setValue( self.prefs.default_limit )
self.use_default_limit.setChecked( self.prefs.use_default_limit )
self.default_until.setValue( self.prefs.default_until_days_interval )
self.use_default_until.setChecked( self.prefs.use_default_until_days_interval )
self.default_since.setValue( self.prefs.default_since_days_interval )
self.use_default_since.setChecked( self.prefs.use_default_since_days_interval )
self.addRow( T_('Default Limit'), self.default_limit, self.use_default_limit )
self.addRow( T_('Default until interval'), self.default_until, self.use_default_until )
self.addRow( T_('Default since interval'), self.default_since, self.use_default_since )
self.default_until.valueChanged.connect( self.__untilChanged )
def __init__(self, option, value):
super().__init__(option)
if isinstance(value, float):
self.number = QW.QDoubleSpinBox()
else:
self.number = QW.QSpinBox()
self.number.setRange(-1000000, 1000000)
self.number.setValue(value)
self.number.installEventFilter(self)
self.layout.addWidget(self.number)
def read_settings(self):
settings = QtCore.QSettings(self._application, self._section)
for key in settings.allKeys():
value = settings.value(key)
try:
# This is required to skip the tab_position key/value
this = getattr(self.ui, key)
except:
continue
if isinstance(this, QW.QLineEdit):
this.setText(value)
elif isinstance(this, QW.QSpinBox):
this.setValue(int(value))
elif isinstance(this, QW.QComboBox):
index = this.findText(value)
this.setCurrentIndex(index)
elif isinstance(this, QW.QCheckBox):
if value in ['false']:
this.setChecked(False)
else:
this.setChecked(True)
else:
print('could not handle : %s' % this)
# The last tab position
self._tab_pos = settings.value("tab_position", 0, type=int)
self.ui.tabs.setCurrentIndex(self._tab_pos)
def setupUi(self, ScientificScroller):
ScientificScroller.setObjectName("ScientificScroller")
ScientificScroller.resize(283, 61)
self.horizontalLayout = QtWidgets.QHBoxLayout(ScientificScroller)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setSpacing(3)
self.horizontalLayout.setObjectName("horizontalLayout")
self.mantissa = QDoubleSpinBoxDotSeparator(ScientificScroller)
self.mantissa.setSpecialValueText("")
self.mantissa.setDecimals(4)
self.mantissa.setMinimum(-1000.0)
self.mantissa.setMaximum(1000.0)
self.mantissa.setSingleStep(0.01)
self.mantissa.setObjectName("mantissa")
self.horizontalLayout.addWidget(self.mantissa)
self.label = QtWidgets.QLabel(ScientificScroller)
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
self.exponent = QtWidgets.QSpinBox(ScientificScroller)
self.exponent.setMinimum(-99)
self.exponent.setObjectName("exponent")
self.horizontalLayout.addWidget(self.exponent)
self.horizontalLayout.setStretch(0, 1)
self.retranslateUi(ScientificScroller)
QtCore.QMetaObject.connectSlotsByName(ScientificScroller)
def __init__(self, parent=None):
super().__init__(parent)
s = plexdesktop.settings.Settings()
self.setWindowTitle('Preferences')
self.form = QtWidgets.QFormLayout(self)
i = QtWidgets.QComboBox()
i.addItems(plexdesktop.style.Style.Instance().themes)
i.setCurrentIndex(i.findText(s.value('theme')))
self.form.addRow(QtWidgets.QLabel('theme'), i)
bf = QtWidgets.QSpinBox()
bf.setValue(int(s.value('browser_font', 9)))
self.form.addRow(QtWidgets.QLabel('browser font size'), bf)
icon_size = QtWidgets.QLineEdit(str(s.value('thumb_size', 240)))
icon_size.setValidator(QtGui.QIntValidator(0, 300))
self.form.addRow(QtWidgets.QLabel('thumbnail size'), icon_size)
widget_player = QtWidgets.QCheckBox()
widget_player.setCheckState(QtCore.Qt.Checked if bool(int(s.value('widget_player', 0))) else QtCore.Qt.Unchecked)
self.form.addRow(QtWidgets.QLabel('use widget player'), widget_player)
self.buttons = QtWidgets.QDialogButtonBox(
QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
QtCore.Qt.Horizontal, self)
self.form.addRow(self.buttons)
self.buttons.rejected.connect(self.reject)
self.buttons.accepted.connect(self.accept)
if self.exec_() == QtWidgets.QDialog.Accepted:
# s = Settings()
theme = i.currentText()
s.setValue('theme', theme)
plexdesktop.style.Style.Instance().theme(theme)
s.setValue('browser_font', bf.value())
s.setValue('thumb_size', int(icon_size.text()))
s.setValue('widget_player', 1 if widget_player.checkState() == QtCore.Qt.Checked else 0)
def getValue(self):
"""
@return: the current value of the QSpinBox
"""
return self.spinbox.value()
def getValue(self):
"""
@return: the current value of the QSpinBox
"""
return str(self.lineedit.text())
def getValue(self):
"""
@return the current value of the QSpinBox (string list)
"""
item_list = str(self.lineedit.text()).split(self.separator)
i = 0
while i < len(item_list):
item_list[i] = item_list[i].strip(' ') #remove leading and trailing whitespaces
i += 1
return item_list
def setCellValue(self, line, column, value):
"""
This function is reimplemented to use QTextEdit into the table, thus allowing multi-lines custom GCODE to be stored
@param line: line number (int)
@param column: column number (int)
@param value: cell content (string or int or float)
"""
if column > 0:
#we use QDoubleSpinBox for storing the values
spinbox = CorrectedDoubleSpinBox()
spinbox.setMinimum(0)
spinbox.setMaximum(1000000000) #Default value is 99
computed_value = 0.0
try: computed_value = float(value) #Convert the value to float
except ValueError: pass
spinbox.setValue(computed_value)
else:
#tool number is an integer
spinbox = QSpinBox()
spinbox.setMinimum(0)
spinbox.setMaximum(1000000000) #Default value is 99
computed_value = 0
try:
computed_value = int(value) #Convert the value to int (we may receive a string for example)
except ValueError:
computed_value = self.max_tool_number + 1
self.max_tool_number = max(self.max_tool_number, computed_value) #Store the max value for the tool number, so that we can automatically increment this value for new tools
spinbox.setValue(computed_value) #first column is the key, it must be an int
self.tablewidget.setCellWidget(line, column, spinbox)
def __init__(self, id_, name="", quantity=0):
super().__init__()
self.id_ = id_
self.input = QtWidgets.QLineEdit()
self.quantity_input = QtWidgets.QSpinBox()
self.quantity_input.setRange(0, 9999)
self.quantity_input.setValue(quantity)
self.quantity_input.setSuffix(" mL")
self.input.setText(name)
self.button = QtWidgets.QPushButton("Supprimer")
self.button.clicked.connect(self.remove)
self.layout = QtWidgets.QHBoxLayout(self)
self.layout.addWidget(self.input)
self.layout.addWidget(self.quantity_input)
self.layout.addWidget(self.button)
def eventFilter(self, obje, even):
if type(even) == QtGui.QWheelEvent:
if type(obje) == QtWidgets.QSpinBox:
if not obje.hasFocus():
even.ignore()
return True
try:
return obje.eventFilter(obje, even)
except:
return False
def apply_changes_impl(self):
for i in Qualification:
name = i.name
if i in self.group.ranking.rank:
rank = self.group.ranking.rank[i]
assert isinstance(rank, RankingItem)
rank.is_active = self.findChild(QCheckBox, name + '_checkbox').isChecked()
rank.max_place = self.findChild(QSpinBox, name + '_place').value()
rank.max_time = time_to_otime(self.findChild(QTimeEdit, name + '_time').time())
rank.use_scores = self.findChild(AdvComboBox, name + '_combo').currentText() == _('Rank')
ResultCalculation().set_rank(self.group)
def setupUi(self, AutoSelectSetting):
AutoSelectSetting.setObjectName("AutoSelectSetting")
AutoSelectSetting.resize(386, 219)
self.buttonBoxQuery = QtWidgets.QDialogButtonBox(AutoSelectSetting)
self.buttonBoxQuery.setGeometry(QtCore.QRect(20, 181, 341, 31))
self.buttonBoxQuery.setOrientation(QtCore.Qt.Horizontal)
self.buttonBoxQuery.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBoxQuery.setObjectName("buttonBoxQuery")
self.gridLayoutWidget = QtWidgets.QWidget(AutoSelectSetting)
self.gridLayoutWidget.setGeometry(QtCore.QRect(20, 40, 160, 81))
self.gridLayoutWidget.setObjectName("gridLayoutWidget")
self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
self.gridLayout.setObjectName("gridLayout")
self.spinBox = QtWidgets.QSpinBox(self.gridLayoutWidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(15)
sizePolicy.setHeightForWidth(self.spinBox.sizePolicy().hasHeightForWidth())
self.spinBox.setSizePolicy(sizePolicy)
self.spinBox.setProperty("value", 1)
self.spinBox.setObjectName("spinBox")
self.gridLayout.addWidget(self.spinBox, 1, 0, 1, 1)
self.label = QtWidgets.QLabel(self.gridLayoutWidget)
font = QtGui.QFont()
font.setPointSize(14)
font.setBold(True)
font.setItalic(True)
font.setWeight(75)
self.label.setFont(font)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
self.retranslateUi(AutoSelectSetting)
self.buttonBoxQuery.accepted.connect(AutoSelectSetting.accept)
self.buttonBoxQuery.rejected.connect(AutoSelectSetting.reject)
QtCore.QMetaObject.connectSlotsByName(AutoSelectSetting)