def __init__(self, data, title="", comment="", icon=None, parent=None, apply=None): super().__init__(parent) self.apply_callback = apply # Form if isinstance(data[0][0], (list, tuple)): self.formwidget = FormTabWidget(data, comment=comment, parent=self) elif len(data[0]) == 3: self.formwidget = FormComboWidget(data, comment=comment, parent=self) else: self.formwidget = FormWidget(data, comment=comment, parent=self) layout = QtWidgets.QVBoxLayout() layout.addWidget(self.formwidget) self.float_fields = [] self.formwidget.setup() # Button box self.bbox = bbox = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.StandardButton( _to_int(_enum("QtWidgets.QDialogButtonBox.StandardButton").Ok) | _to_int( _enum("QtWidgets.QDialogButtonBox.StandardButton").Cancel)) ) self.formwidget.update_buttons.connect(self.update_buttons) if self.apply_callback is not None: apply_btn = bbox.addButton( _enum("QtWidgets.QDialogButtonBox.StandardButton").Apply) apply_btn.clicked.connect(self.apply) bbox.accepted.connect(self.accept) bbox.rejected.connect(self.reject) layout.addWidget(bbox) self.setLayout(layout) self.setWindowTitle(title) if not isinstance(icon, QtGui.QIcon): icon = QtWidgets.QWidget().style().standardIcon( QtWidgets.QStyle.SP_MessageBoxQuestion) self.setWindowIcon(icon)
def __init__(self,parent=None,selected=None,raw_adc=False,raw_time=False,pedestal=None,distribute=None,fft=False,**ignored): super().__init__(parent) self._layout = QtWidgets.QVBoxLayout(self) self.set_selected(selected) self.fft_checkbox = QtWidgets.QCheckBox('Plot FFT') self.fft_checkbox.setCheckState(QtCore.Qt.Checked if fft else QtCore.Qt.Unchecked) self._layout.addWidget(self.fft_checkbox) self.raw_checkbox = QtWidgets.QCheckBox('Plot raw ADC counts') self.raw_checkbox.setCheckState(QtCore.Qt.Checked if raw_adc else QtCore.Qt.Unchecked) self._layout.addWidget(self.raw_checkbox) self.raw_time_checkbox = QtWidgets.QCheckBox('Plot sample index') self.raw_time_checkbox.setCheckState(QtCore.Qt.Checked if raw_time else QtCore.Qt.Unchecked) self._layout.addWidget(self.raw_time_checkbox) redist_layout = QtWidgets.QHBoxLayout() self.redist_checkbox = QtWidgets.QCheckBox('Redistribute signals') self.redist_checkbox.setCheckState(QtCore.Qt.Checked if distribute else QtCore.Qt.Unchecked) redist_layout.addWidget(self.redist_checkbox) self.redist_amount = QtWidgets.QLineEdit('0' if distribute is None else str(distribute)) redist_layout.addWidget(self.redist_amount) self._layout.addLayout(redist_layout) ped_layout = QtWidgets.QHBoxLayout() self.baseline_checkbox = QtWidgets.QCheckBox('Correct baselines') self.baseline_checkbox.setCheckState(QtCore.Qt.Checked if pedestal else QtCore.Qt.Unchecked) ped_layout.addWidget(self.baseline_checkbox) self.ped_min = QtWidgets.QLineEdit('0' if pedestal is None else str(pedestal[0])) self.ped_min.setFixedWidth(100) ped_layout.addWidget(self.ped_min) self.ped_max = QtWidgets.QLineEdit('50' if pedestal is None else str(pedestal[1])) self.ped_max.setFixedWidth(100) ped_layout.addWidget(self.ped_max) self._layout.addLayout(ped_layout) buttons = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) self._layout.addWidget(buttons)
def reshape_prompt(self): dialog = QtWidgets.QDialog() layout = QtWidgets.QFormLayout() layout.addRow(QtWidgets.QLabel("Choose Plot Grid Shape")) rowbox,colbox = QtWidgets.QLineEdit(str(self.rows)),QtWidgets.QLineEdit(str(self.cols)) layout.addRow(QtWidgets.QLabel("Rows"),rowbox) layout.addRow(QtWidgets.QLabel("Cols"),colbox) buttons = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, dialog) buttons.accepted.connect(dialog.accept) buttons.rejected.connect(dialog.reject) layout.addWidget(buttons) dialog.setLayout(layout) if dialog.exec_() == QtWidgets.QDialog.Accepted: try: r = int(rowbox.text()) c = int(colbox.text()) self.reshape(r,c) except: print('Invalid input to reshape dialog')
def __init__(self, field_specs): super(SimpleDialog, self).__init__() self.layout = QtWidgets.QVBoxLayout(self) self.field_specs = field_specs self.fields = {} for spec in field_specs: if spec['type'] == 'lineedit': self.add_QLineEdit(spec) elif spec['type'] == 'datetimeedit': self.add_QDateTimeEdit(spec) else: raise ValueError('unrecognized spec: %s' % spec) # OK and Cancel buttons self.buttons = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, Qt.Horizontal, self) self.layout.addWidget(self.buttons) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject)
def __init__(self, parent = None): super(DateDialog, self).__init__(parent) layout = QtWidgets.QVBoxLayout(self) label = QtWidgets.QLabel(self) label.setObjectName(_fromUtf8("label")) label.setText(_translate("RefWindow", "When was the reference level changed?", None)) layout.addWidget(label) # nice widget for editing the date self.datetime = QtWidgets.QDateTimeEdit(self) self.datetime.setCalendarPopup(True) self.datetime.setDateTime(QtCore.QDateTime.currentDateTime()) self.datetime.setDisplayFormat("yyyy-MM-dd HH:mm") layout.addWidget(self.datetime) # OK and Cancel buttons buttons = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) layout.addWidget(buttons)