def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setObjectName("SubplotTool") self._widgets = {} layout = QtWidgets.QHBoxLayout() self.setLayout(layout) left = QtWidgets.QVBoxLayout() layout.addLayout(left) right = QtWidgets.QVBoxLayout() layout.addLayout(right) box = QtWidgets.QGroupBox("Borders") left.addWidget(box) inner = QtWidgets.QFormLayout(box) for side in ["top", "bottom", "left", "right"]: self._widgets[side] = widget = QtWidgets.QDoubleSpinBox() widget.setMinimum(0) widget.setMaximum(1) widget.setDecimals(3) widget.setSingleStep(.005) widget.setKeyboardTracking(False) inner.addRow(side, widget) left.addStretch(1) box = QtWidgets.QGroupBox("Spacings") right.addWidget(box) inner = QtWidgets.QFormLayout(box) for side in ["hspace", "wspace"]: self._widgets[side] = widget = QtWidgets.QDoubleSpinBox() widget.setMinimum(0) widget.setMaximum(1) widget.setDecimals(3) widget.setSingleStep(.005) widget.setKeyboardTracking(False) inner.addRow(side, widget) right.addStretch(1) widget = QtWidgets.QPushButton("Export values") self._widgets["Export values"] = widget # Don't trigger on <enter>, which is used to input values. widget.setAutoDefault(False) left.addWidget(widget) for action in ["Tight layout", "Reset", "Close"]: self._widgets[action] = widget = QtWidgets.QPushButton(action) widget.setAutoDefault(False) right.addWidget(widget) self._widgets["Close"].setFocus()
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setObjectName("SubplotTool") self._widgets = {} main_layout = QtWidgets.QHBoxLayout() self.setLayout(main_layout) for group, spinboxes, buttons in [ ("Borders", ["top", "bottom", "left", "right"], ["Export values"]), ("Spacings", ["hspace", "wspace"], ["Tight layout", "Reset", "Close"]), ]: layout = QtWidgets.QVBoxLayout() main_layout.addLayout(layout) box = QtWidgets.QGroupBox(group) layout.addWidget(box) inner = QtWidgets.QFormLayout(box) for name in spinboxes: self._widgets[name] = widget = QtWidgets.QDoubleSpinBox() widget.setMinimum(0) widget.setMaximum(1) widget.setDecimals(3) widget.setSingleStep(0.005) widget.setKeyboardTracking(False) inner.addRow(name, widget) layout.addStretch(1) for name in buttons: self._widgets[name] = widget = QtWidgets.QPushButton(name) # Don't trigger on <enter>, which is used to input values. widget.setAutoDefault(False) layout.addWidget(widget) self._widgets["Close"].setFocus()
def setup_figure(self): self.ui.start_pushButton.clicked.connect(self.start) self.ui.interrupt_pushButton.clicked.connect(self.interrupt) self.settings.x_axis.connect_to_widget(self.ui.x_axis_comboBox) self.settings.x_axis.add_listener(self.update_display) self.acq_mode.connect_to_widget(self.ui.acq_mode_comboBox) if hasattr(self, 'shutter_open'): CB_widget = QtWidgets.QCheckBox('use shutter') self.settings.use_shutter.connect_to_widget(CB_widget) self.ui.power_scan_GroupBox.layout().addWidget(CB_widget) else: self.settings['use_shutter'] = False self.settings.use_shutter.change_readonly(True) self.settings.manual_acq_times.connect_to_widget(self.ui.manual_acq_times_lineEdit) self.ui.manual_acq_times_lineEdit.setVisible(False) self.settings.acq_mode.add_listener(self.on_change_acq_mode) self.power_wheel_range.min.connect_to_widget(self.ui.power_wheel_min_doubleSpinBox) self.power_wheel_range.max.connect_to_widget(self.ui.power_wheel_max_doubleSpinBox) self.power_wheel_range.num.connect_to_widget(self.ui.power_wheel_num_doubleSpinBox) self.power_wheel_range.step.connect_to_widget(self.ui.power_wheel_step_doubleSpinBox) self.power_wheel_range.sweep_type.connect_to_widget(self.ui.sweep_type_comboBox) # Hardware connections layout = self.ui.collect_groupBox.layout() hw_list = self.app.hardware.keys() self.installed_hw = {} for key in self.hws.keys(): if key in hw_list: CB_widget = QtWidgets.QCheckBox(key) lq = getattr(self.settings, 'collect_{}'.format(key)) lq.connect_to_widget(CB_widget) SP_widget = QtWidgets.QDoubleSpinBox() Tacq_lq = getattr(self.app.hardware[key].settings, self.hws[key]) Tacq_lq.connect_to_widget(SP_widget) layout.addRow(CB_widget, SP_widget) self.installed_hw.update({key: Tacq_lq}) # Plot if hasattr(self, 'graph_layout'): self.graph_layout.deleteLater() # see http://stackoverflow.com/questions/9899409/pyside-removing-a-widget-from-a-layout del self.graph_layout self.graph_layout=pg.GraphicsLayoutWidget() self.ui.plot_groupBox.layout().addWidget(self.graph_layout) self.power_plot = self.graph_layout.addPlot(title="Power Scan") self.display_ready = False self.status = {'title':'starting power scan', 'color':'y'}
def LoadFile(self): self.ClearSpace() name,_ = QtWidgets.QFileDialog.getOpenFileName(self, 'Open File','./','All files(*)') df = pd.read_csv(name) self.weights = list() counter = 0 for name, value in df.items(): if counter==0: self.a = np.array(value) else: self.weights.append(np.array(value)) counter += 1 self.weights = np.array(self.weights) self.classes.setValue(len(self.weights)) self.dimensions.setValue(len(self.weights[0])) for i in range(self.classes.value()+1): weightValues = list() hLayout = QtWidgets.QHBoxLayout() if i==0: weightName = QtWidgets.QLabel('Ae:') else: weightName = QtWidgets.QLabel('W'+str(i)+':') hLayout.addWidget(weightName) for j in range(self.dimensions.value()): if i==0: weightValues.append(QtWidgets.QDoubleSpinBox(minimum=-999.999, maximum=999.999, maximumWidth=81,singleStep=0.1, value=self.a[j], decimals=3)) hLayout.addWidget(weightValues[j]) else: weightValues.append(QtWidgets.QDoubleSpinBox(minimum=-999.999, maximum=999.999, maximumWidth=81,singleStep=0.1, value=self.weights[i-1,j], decimals=3)) hLayout.addWidget(weightValues[j]) self.vLayout.addLayout(hLayout) self.boxValues.append(weightValues) self.weightNames.append(weightName) self.boxValues = np.array(self.boxValues) pass
def CreateSpace(self): self.ClearSpace() for i in range(self.classes.value()+1): weightValues = list() hLayout = QtWidgets.QHBoxLayout() if i==0: weightName = QtWidgets.QLabel('Ae:') else: weightName = QtWidgets.QLabel('W'+str(i)+':') hLayout.addWidget(weightName) for j in range(self.dimensions.value()): weightValues.append(QtWidgets.QDoubleSpinBox(minimum=-999.999, maximum=999.999, maximumWidth=81,singleStep=0.1, value=np.random.randn(1), decimals=3)) hLayout.addWidget(weightValues[j]) self.vLayout.addLayout(hLayout) self.boxValues.append(weightValues) self.weightNames.append(weightName) self.boxValues = np.array(self.boxValues) self.a = np.array([self.boxValues[0,i].value() for i in range(len(self.boxValues[0]))]) self.weights = np.array([[self.boxValues[i,j].value() for j in range(len(self.boxValues[i]))] for i in range(1,len(self.boxValues))]) pass