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 get_canvas2_layout(self): self.canvas2 = QtWidgets.QGroupBox('Canvas 2') # canvas 2 self.fig2 = FigureCanvas(Figure(figsize=(0.5, 1.5))) self._ax2 = self.fig2.figure.subplots() self.fig2.figure.subplots_adjust(0.15, 0.19, 0.95, 0.95) # range of canvas 2 self.r2 = [] for idx, label in enumerate(['X range: ', 'Y range: ']): self.r2.append(QtWidgets.QLabel(label, self)) self.r2.append( QtWidgets.QLineEdit('{:4.3f}'.format(self.range2[idx][0]), self)) self.r2.append(QtWidgets.QLabel(' to ', self)) self.r2.append( QtWidgets.QLineEdit('{:4.3f}'.format(self.range2[idx][1]), self)) for idx in np.arange(1, 9, 2): self.r2[idx].returnPressed.connect(self.update_range2) # go button self.updaterange2button = QtWidgets.QPushButton('Update Range', self) self.updaterange2button.clicked.connect(self.update_range2) # the layout layout = QtWidgets.QGridLayout() layout.addWidget(self.fig2, 0, 0, 1, 9) for idx in np.arange(8): layout.addWidget(self.r2[idx], 1, idx) layout.addWidget(self.updaterange2button, 1, 8) self.canvas2.setLayout(layout)
def get_Galtemplate_layout(self): self.Galtemplate = QtWidgets.QGroupBox('Galaxy Template') self.Galplot = QtWidgets.QCheckBox('Plot template', self) self.Galz_label = QtWidgets.QLabel('z = ', self) self.Galz = QtWidgets.QLineEdit('{:5.4f}'.format(self.z[1]), self) self.Galcolor_label = QtWidgets.QLabel('Color: ', self) self.Galcolor = QtWidgets.QLineEdit(self.linecolor[1], self) self.Galscale_label = QtWidgets.QLabel('Scale factor: ', self) self.Galscale = QtWidgets.QLineEdit('{:5.2f}'.format( self.linescale[1], self)) self.Gallabels = QtWidgets.QCheckBox('Plot labels', self) self.Galplot.stateChanged.connect(self.update_figures) self.Galz.returnPressed.connect(self.update_redshifts) self.Galcolor.returnPressed.connect(self.update_linecolors) self.Galscale.returnPressed.connect(self.update_linescales) self.Gallabels.stateChanged.connect(self.update_figures) # the layout layout = QtWidgets.QGridLayout() layout.addWidget(self.Galplot, 0, 0, 1, 2) layout.addWidget(self.Gallabels, 0, 2, 1, 2) layout.addWidget(self.Galz_label, 1, 0, 1, 1) layout.addWidget(self.Galz, 1, 1, 1, 1) layout.addWidget(self.Galscale_label, 1, 2, 1, 1) layout.addWidget(self.Galscale, 1, 3, 1, 1) layout.addWidget(self.Galcolor_label, 2, 0, 1, 1) layout.addWidget(self.Galcolor, 2, 1, 1, 1) self.Galtemplate.setLayout(layout)
def get_chanselect_layout(self): self.chanselect = QtWidgets.QGroupBox('Channel Select Controls') # create the channel slider self.channelslider = QtWidgets.QScrollBar(QtCore.Qt.Horizontal, self) self.channelslider.setRange(0, self.nchannels - 1) self.channelslider.valueChanged.connect(self.channelslider_changed) # define the channel text box self.channeltext_label = QtWidgets.QLabel(self) self.channeltext_label.setText('Channel: ') self.channeltext = QtWidgets.QLineEdit(str(self.channel), self) self.channeltext.setToolTip('The channel number you want to display') self.channeltext.returnPressed.connect(self.channeltext_changed) # RMS value self.rms = QtWidgets.QLabel(self) self.rms.setText('RMS value: {:10.7f}'.format(self.rmsval)) # layout layout = QtWidgets.QGridLayout() layout.addWidget(self.channeltext_label, 0, 0) layout.addWidget(self.channeltext, 0, 1) layout.addWidget(self.channelslider, 1, 0, 1, 2) layout.addWidget(self.rms, 2, 0, 1, 2) self.chanselect.setLayout(layout)
def get_plotselection_layout(self): self.plotselection = QtWidgets.QGroupBox('Plot Selection') # raster image and contour button group self.bgdata_label = QtWidgets.QLabel('Raster:', self) self.bgcont_label = QtWidgets.QLabel('Contour:', self) self.bgdata = QtWidgets.QButtonGroup(self) self.bgcont = QtWidgets.QButtonGroup(self) self.databutton = [] self.contbutton = [] for button in ['Channels', 'Moment-0', 'Moment-1', 'Moment-2', 'None']: self.databutton.append(QtWidgets.QRadioButton(button)) self.contbutton.append(QtWidgets.QRadioButton(button)) self.bgdata.addButton(self.databutton[-1]) self.bgcont.addButton(self.contbutton[-1]) self.databutton[0].setChecked(True) self.contbutton[-1].setChecked(True) self.bgdata.buttonClicked.connect(self.initiate_dataplot) self.bgcont.buttonClicked.connect(self.initiate_contplot) # create layout layout = QtWidgets.QGridLayout() layout.addWidget(self.bgdata_label, 0, 0) layout.addWidget(self.bgcont_label, 0, 1) for idx, button in enumerate(self.databutton): layout.addWidget(button, idx + 1, 0) for idx, button in enumerate(self.contbutton): layout.addWidget(button, idx + 1, 1) self.plotselection.setLayout(layout)
def get_dataselection_layout(self): self.dataselection = QtWidgets.QGroupBox('Data selection') # range self.r = [] for idx, label in enumerate(['X: ', 'Y: ', 'Channel: ']): self.r.append(QtWidgets.QLabel(label, self)) self.r.append( QtWidgets.QLineEdit('{:4d}'.format(self.range[idx][0]), self)) self.r.append(QtWidgets.QLabel(' to ', self)) self.r.append( QtWidgets.QLineEdit('{:4d}'.format(self.range[idx][1]), self)) # go button self.slicebutton = QtWidgets.QPushButton('Slice', self) self.slicebutton.clicked.connect(self.update_dataselection) # create layout layout = QtWidgets.QGridLayout() for idx in np.arange(3): layout.addWidget(self.r[4 * idx], idx, 0) layout.addWidget(self.r[4 * idx + 1], idx, 1) layout.addWidget(self.r[4 * idx + 2], idx, 2) layout.addWidget(self.r[4 * idx + 3], idx, 3) layout.addWidget(self.slicebutton, 3, 0, 1, 4) self.dataselection.setLayout(layout)
def get_controls_layout(self): self.controls = QtWidgets.QGroupBox('Image controls') # min and max values self.min_label = QtWidgets.QLabel(self) self.min_label.setText('Min: ') self.min = QtWidgets.QLineEdit('{:10.7f}'.format(self.vmin), self) self.min.setToolTip('The minimum value to display') self.min.returnPressed.connect(self.update_min) self.max_label = QtWidgets.QLabel(self) self.max_label.setText('Max: ') self.max = QtWidgets.QLineEdit('{:10.7f}'.format(self.vmax), self) self.max.setToolTip('The maxmimum value to display.') self.max.returnPressed.connect(self.update_max) # Contour value for scaling self.contval_label = QtWidgets.QLabel(self) self.contval_label.setText('Contour value: ') self.contval = QtWidgets.QLineEdit('{:10.7f}'.format(self.cval), self) self.contval.setToolTip('Value used to calculate the contour levels.') self.contval.returnPressed.connect(self.update_contourvalue) # Contour levels self.levels_label = QtWidgets.QLabel(self) self.levels_label.setText('Contour levels: ') self.levels = QtWidgets.QLineEdit(__arrtostr__(self.contours), self) self.levels.setToolTip('Contours levels to display ' + '(in terms of RMS). Should be a list of ' + 'floats separated by commas.') self.levels.returnPressed.connect(self.update_contourlevels) # color map self.colormap_label = QtWidgets.QLabel(self) self.colormap_label.setText('Colormap: ') self.colormap = QtWidgets.QLineEdit('{}'.format(self.cmap), self) self.colormap.setToolTip('The color map to use for the display') self.colormap.returnPressed.connect(self.update_colormap) # Contour colors self.levelcolor_label = QtWidgets.QLabel(self) self.levelcolor_label.setText('Contour Color: ') self.levelcolor = QtWidgets.QLineEdit('{}'.format(self.ccolor), self) self.levelcolor.setToolTip('The color of the contours') self.levelcolor.returnPressed.connect(self.update_contourcolor) # create layout layout = QtWidgets.QGridLayout() layout.addWidget(self.min_label, 0, 0) layout.addWidget(self.min, 0, 1) layout.addWidget(self.max_label, 1, 0) layout.addWidget(self.max, 1, 1) layout.addWidget(self.contval_label, 0, 2) layout.addWidget(self.contval, 0, 3) layout.addWidget(self.levels_label, 1, 2) layout.addWidget(self.levels, 1, 3) layout.addWidget(self.colormap_label, 0, 4) layout.addWidget(self.colormap, 0, 5) layout.addWidget(self.levelcolor_label, 1, 4) layout.addWidget(self.levelcolor, 1, 5) self.controls.setLayout(layout)
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 get_canvas_layout(self): self.canvas = QtWidgets.QGroupBox('Canvas') # the canvas self.fig = FigureCanvas(Figure(figsize=(5, 5))) self._ax = self.fig.figure.subplots() # the layout layout = QtWidgets.QGridLayout() layout.addWidget(self.fig, 0, 0) self.canvas.setLayout(layout)
def get_print_layout(self): self.print = QtWidgets.QGroupBox('Save figure') self.savefile_label = QtWidgets.QLabel('File:', self) self.savefile = QtWidgets.QLineEdit('./JWSTfilter.pdf', self) self.savec1 = QtWidgets.QCheckBox('Canvas 1', self) self.savec2 = QtWidgets.QCheckBox('Canvas 2', self) self.save = QtWidgets.QPushButton('Save', self) self.save.clicked.connect(self.save_figures) layout = QtWidgets.QGridLayout() layout.addWidget(self.savefile_label, 0, 0) layout.addWidget(self.savefile, 0, 1, 1, 2) layout.addWidget(self.savec1, 1, 0, 1, 1) layout.addWidget(self.savec2, 1, 1, 1, 1) layout.addWidget(self.save, 1, 2, 1, 1) self.print.setLayout(layout)
def get_canvas2_layout(self): self.canvas2 = QtWidgets.QGroupBox('Canvas 2') # the image selection buttons self.im2_bg_label = QtWidgets.QLabel(self) self.im2_bg_label.setText('Image: ') self.im2_buttons = [ QtWidgets.QRadioButton('Data'), QtWidgets.QRadioButton('Model'), QtWidgets.QRadioButton('Residual'), QtWidgets.QRadioButton('None') ] self.im2_buttons[1].setChecked(True) self.im2_bg = QtWidgets.QButtonGroup(self) for button in self.im2_buttons: self.im2_bg.addButton(button) self.im2_bg.buttonClicked.connect(self.update_figures) # the contour selection buttons self.co2_bg_label = QtWidgets.QLabel(self) self.co2_bg_label.setText('Contours: ') self.co2_buttons = [ QtWidgets.QRadioButton('Data'), QtWidgets.QRadioButton('Model'), QtWidgets.QRadioButton('Residual'), QtWidgets.QRadioButton('None') ] self.co2_buttons[3].setChecked(True) self.co2_bg = QtWidgets.QButtonGroup(self) for button in self.co2_buttons: self.co2_bg.addButton(button) self.co2_bg.buttonClicked.connect(self.update_figures) # the canvas self.fig2 = FigureCanvas(Figure(figsize=(5, 5))) self._ax2 = self.fig2.figure.subplots() # the layout layout = QtWidgets.QGridLayout() layout.addWidget(self.fig2, 0, 0, 6, 6) layout.addWidget(self.im2_bg_label, 6, 0) for idx, button in enumerate(self.im2_buttons): layout.addWidget(button, 6, idx + 1) layout.addWidget(self.co2_bg_label, 7, 0) for idx, button in enumerate(self.co2_buttons): layout.addWidget(button, 7, idx + 1) self.canvas2.setLayout(layout)
def get_moment_layout(self): self.moment = QtWidgets.QGroupBox('Moment') # The moment range boxes self.mr = [] self.mr.append(QtWidgets.QLabel('Channel:', self)) self.mr.append( QtWidgets.QLineEdit('{:4d}'.format(self.range[2][0]), self)) self.mr.append(QtWidgets.QLabel(' to ', self)) self.mr.append( QtWidgets.QLineEdit('{:4d}'.format(self.range[2][1]), self)) # The mask buttons self.momentmask = [] masklabel = [ 'Use mask for moment-0 with values above RMS of: ', 'Use mask for moment-1 with values above RMS of: ', 'Use mask for moment-2 with values above RMS of: ' ] for label in masklabel: self.momentmask.append(QtWidgets.QCheckBox(label)) self.momentmaskvalue = [] for mmval in self.mmaskval: self.momentmaskvalue.append( QtWidgets.QLineEdit('{:10.7f}'.format(mmval), self)) # Gaussian moment plot self.gaussianmoment = QtWidgets.QCheckBox('Gaussian moment') self.gaussianmoment.setChecked(False) # update moment button self.momentbutton = QtWidgets.QPushButton('Calculate Moments', self) self.momentbutton.clicked.connect(self.get_moments) # create layout layout = QtWidgets.QGridLayout() for idx in np.arange(4): layout.addWidget(self.mr[idx], 0, idx) for idx in np.arange(3): layout.addWidget(self.momentmask[idx], idx + 1, 0, 1, 3) layout.addWidget(self.momentmaskvalue[idx], idx + 1, 3) layout.addWidget(self.gaussianmoment, 4, 0, 1, 4) layout.addWidget(self.momentbutton, 5, 0, 1, 4) self.moment.setLayout(layout)
def get_NIRSpec_layout(self): self.NIRSpec = QtWidgets.QGroupBox('NIRSpec spectral ranges') self.Nspec = [] for idx, filt in enumerate(self.Nsmodes): self.Nspec.append(QtWidgets.QCheckBox(filt, self)) self.Nspec.append(QtWidgets.QLabel('Color: ', self)) self.Nspec.append( QtWidgets.QLineEdit('{:6.4f}'.format(self.Nscolors[idx]), self)) for idx in np.arange(len(self.Nsmodes)): self.Nspec[3 * idx].stateChanged.connect(self.update_figures) self.Nspec[3 * idx + 2].returnPressed.connect( self.update_Nspeccolor) self.Nsselectall = QtWidgets.QPushButton('Select all', self) self.Nsselectall.clicked.connect(self.update_Nsselectall) # the layout layout = QtWidgets.QGridLayout() for idx in np.arange(len(self.Nsmodes)): for idx2 in np.arange(3): layout.addWidget(self.Nspec[3 * idx + idx2], idx, idx2) layout.addWidget(self.Nsselectall, 3 * idx + 1, 0, 1, 2) self.NIRSpec.setLayout(layout)
def get_MIRIfilters_layout(self): self.MIRIfilter = QtWidgets.QGroupBox('MIRI filters') self.Mfilter = [] for idx, filt in enumerate(self.Mfilters): self.Mfilter.append(QtWidgets.QCheckBox(filt, self)) self.Mfilter.append(QtWidgets.QLabel('Color: ', self)) self.Mfilter.append( QtWidgets.QLineEdit('{:6.4f}'.format(self.Mfcolors[idx]), self)) for idx in np.arange(len(self.Mfilters)): self.Mfilter[3 * idx].stateChanged.connect(self.update_figures) self.Mfilter[3 * idx + 2].returnPressed.connect( self.update_Mfiltercolor) self.Mfselectall = QtWidgets.QPushButton('Select all', self) self.Mfselectall.clicked.connect(self.update_Mfselectall) # the layout layout = QtWidgets.QGridLayout() for idx in np.arange(len(self.Mfilters)): for idx2 in np.arange(3): layout.addWidget(self.Mfilter[3 * idx + idx2], idx, idx2) layout.addWidget(self.Mfselectall, 3 * idx + 1, 0, 1, 2) self.MIRIfilter.setLayout(layout)
def get_parameter_layout(self): self.parameter = QtWidgets.QGroupBox('Model Parameters') # line edits for all of the parameters self.nparameters = len(self.qube.initpar) self.lepar_label = [] self.lepar = [] for idx, key in enumerate(self.qube.initpar.keys()): self.lepar_label.append(QtWidgets.QLabel(self)) self.lepar_label[idx].setText(key + ': ') strval = str(self.qube.initpar[key]['Value']) self.lepar.append(QtWidgets.QLineEdit(strval, self)) # the GO button self.gobutton = QtWidgets.QPushButton('OK', self) self.gobutton.clicked.connect(self.update_model) # layout layout = QtWidgets.QGridLayout() for idx in np.arange(self.nparameters): layout.addWidget(self.lepar_label[idx], idx, 0) layout.addWidget(self.lepar[idx], idx, 1) layout.addWidget(self.gobutton, idx + 1, 0, 1, 2) self.parameter.setLayout(layout)
def __init__(self, *args, **kwargs): super(UiSubplotTool, self).__init__(*args, **kwargs) self.setObjectName('SubplotTool') self.resize(450, 265) gbox = QtWidgets.QGridLayout(self) self.setLayout(gbox) # groupbox borders groupbox = QtWidgets.QGroupBox('Borders', self) gbox.addWidget(groupbox, 6, 0, 1, 1) self.verticalLayout = QtWidgets.QVBoxLayout(groupbox) self.verticalLayout.setSpacing(0) # slider top self.hboxtop = QtWidgets.QHBoxLayout() self.labeltop = QtWidgets.QLabel('top', self) self.labeltop.setMinimumSize(QtCore.QSize(50, 0)) self.labeltop.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.slidertop = QtWidgets.QSlider(self) self.slidertop.setMouseTracking(False) self.slidertop.setProperty("value", 0) self.slidertop.setOrientation(QtCore.Qt.Horizontal) self.slidertop.setInvertedAppearance(False) self.slidertop.setInvertedControls(False) self.slidertop.setTickPosition(QtWidgets.QSlider.TicksAbove) self.slidertop.setTickInterval(100) self.topvalue = QtWidgets.QLabel('0', self) self.topvalue.setMinimumSize(QtCore.QSize(30, 0)) self.topvalue.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.verticalLayout.addLayout(self.hboxtop) self.hboxtop.addWidget(self.labeltop) self.hboxtop.addWidget(self.slidertop) self.hboxtop.addWidget(self.topvalue) # slider bottom hboxbottom = QtWidgets.QHBoxLayout() labelbottom = QtWidgets.QLabel('bottom', self) labelbottom.setMinimumSize(QtCore.QSize(50, 0)) labelbottom.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.sliderbottom = QtWidgets.QSlider(self) self.sliderbottom.setMouseTracking(False) self.sliderbottom.setProperty("value", 0) self.sliderbottom.setOrientation(QtCore.Qt.Horizontal) self.sliderbottom.setInvertedAppearance(False) self.sliderbottom.setInvertedControls(False) self.sliderbottom.setTickPosition(QtWidgets.QSlider.TicksAbove) self.sliderbottom.setTickInterval(100) self.bottomvalue = QtWidgets.QLabel('0', self) self.bottomvalue.setMinimumSize(QtCore.QSize(30, 0)) self.bottomvalue.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.verticalLayout.addLayout(hboxbottom) hboxbottom.addWidget(labelbottom) hboxbottom.addWidget(self.sliderbottom) hboxbottom.addWidget(self.bottomvalue) # slider left hboxleft = QtWidgets.QHBoxLayout() labelleft = QtWidgets.QLabel('left', self) labelleft.setMinimumSize(QtCore.QSize(50, 0)) labelleft.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.sliderleft = QtWidgets.QSlider(self) self.sliderleft.setMouseTracking(False) self.sliderleft.setProperty("value", 0) self.sliderleft.setOrientation(QtCore.Qt.Horizontal) self.sliderleft.setInvertedAppearance(False) self.sliderleft.setInvertedControls(False) self.sliderleft.setTickPosition(QtWidgets.QSlider.TicksAbove) self.sliderleft.setTickInterval(100) self.leftvalue = QtWidgets.QLabel('0', self) self.leftvalue.setMinimumSize(QtCore.QSize(30, 0)) self.leftvalue.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.verticalLayout.addLayout(hboxleft) hboxleft.addWidget(labelleft) hboxleft.addWidget(self.sliderleft) hboxleft.addWidget(self.leftvalue) # slider right hboxright = QtWidgets.QHBoxLayout() self.labelright = QtWidgets.QLabel('right', self) self.labelright.setMinimumSize(QtCore.QSize(50, 0)) self.labelright.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.sliderright = QtWidgets.QSlider(self) self.sliderright.setMouseTracking(False) self.sliderright.setProperty("value", 0) self.sliderright.setOrientation(QtCore.Qt.Horizontal) self.sliderright.setInvertedAppearance(False) self.sliderright.setInvertedControls(False) self.sliderright.setTickPosition(QtWidgets.QSlider.TicksAbove) self.sliderright.setTickInterval(100) self.rightvalue = QtWidgets.QLabel('0', self) self.rightvalue.setMinimumSize(QtCore.QSize(30, 0)) self.rightvalue.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.verticalLayout.addLayout(hboxright) hboxright.addWidget(self.labelright) hboxright.addWidget(self.sliderright) hboxright.addWidget(self.rightvalue) # groupbox spacings groupbox = QtWidgets.QGroupBox('Spacings', self) gbox.addWidget(groupbox, 7, 0, 1, 1) self.verticalLayout = QtWidgets.QVBoxLayout(groupbox) self.verticalLayout.setSpacing(0) # slider hspace hboxhspace = QtWidgets.QHBoxLayout() self.labelhspace = QtWidgets.QLabel('hspace', self) self.labelhspace.setMinimumSize(QtCore.QSize(50, 0)) self.labelhspace.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.sliderhspace = QtWidgets.QSlider(self) self.sliderhspace.setMouseTracking(False) self.sliderhspace.setProperty("value", 0) self.sliderhspace.setOrientation(QtCore.Qt.Horizontal) self.sliderhspace.setInvertedAppearance(False) self.sliderhspace.setInvertedControls(False) self.sliderhspace.setTickPosition(QtWidgets.QSlider.TicksAbove) self.sliderhspace.setTickInterval(100) self.hspacevalue = QtWidgets.QLabel('0', self) self.hspacevalue.setMinimumSize(QtCore.QSize(30, 0)) self.hspacevalue.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.verticalLayout.addLayout(hboxhspace) hboxhspace.addWidget(self.labelhspace) hboxhspace.addWidget(self.sliderhspace) hboxhspace.addWidget(self.hspacevalue) # slider hspace # slider wspace hboxwspace = QtWidgets.QHBoxLayout() self.labelwspace = QtWidgets.QLabel('wspace', self) self.labelwspace.setMinimumSize(QtCore.QSize(50, 0)) self.labelwspace.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.sliderwspace = QtWidgets.QSlider(self) self.sliderwspace.setMouseTracking(False) self.sliderwspace.setProperty("value", 0) self.sliderwspace.setOrientation(QtCore.Qt.Horizontal) self.sliderwspace.setInvertedAppearance(False) self.sliderwspace.setInvertedControls(False) self.sliderwspace.setTickPosition(QtWidgets.QSlider.TicksAbove) self.sliderwspace.setTickInterval(100) self.wspacevalue = QtWidgets.QLabel('0', self) self.wspacevalue.setMinimumSize(QtCore.QSize(30, 0)) self.wspacevalue.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.verticalLayout.addLayout(hboxwspace) hboxwspace.addWidget(self.labelwspace) hboxwspace.addWidget(self.sliderwspace) hboxwspace.addWidget(self.wspacevalue) # button bar hbox2 = QtWidgets.QHBoxLayout() gbox.addLayout(hbox2, 8, 0, 1, 1) self.tightlayout = QtWidgets.QPushButton('Tight Layout', self) spacer = QtWidgets.QSpacerItem(5, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.resetbutton = QtWidgets.QPushButton('Reset', self) self.donebutton = QtWidgets.QPushButton('Close', self) self.donebutton.setFocus() hbox2.addWidget(self.tightlayout) hbox2.addItem(spacer) hbox2.addWidget(self.resetbutton) hbox2.addWidget(self.donebutton) self.donebutton.clicked.connect(self.accept)
def initMaintab(self): self._main.gridlayout = QtWidgets.QGridLayout() self.sequence_box = QtWidgets.QPlainTextEdit(self._main) self.vertex_box = QtWidgets.QPlainTextEdit(self._main) self.condition_box = QtWidgets.QPlainTextEdit(self._main) self.condition_box.resize(32, 8) self.actual_line = QtWidgets.QLabel(self._main) self.actual_line.setText('No sequence started') self.write_sequence() self.write_v80parms() self.write_conditions() self._main.gridlayout.addWidget(self.actual_line, 0, 1, 1, 2) self._main.gridlayout.addWidget(self.sequence_box, 1, 1, 5, 2) self._main.gridlayout.addWidget(self.vertex_box, 6, 1, 5, 2) self._main.gridlayout.addWidget(self.condition_box, 11, 1, 2, 2) loadseq_button = QtWidgets.QPushButton('Load sequence', self._main) loadseq_button.setToolTip("Load Sequence") self._main.gridlayout.addWidget(loadseq_button, 0, 0, 1, 1) loadseq_button.clicked.connect(self.Choose_SequenceFile) run_button = QtWidgets.QPushButton('Run Sequence', self._main) run_button.setToolTip("Run Sequence") self._main.gridlayout.addWidget(run_button, 1, 0, 1, 1) run_button.clicked.connect(self.start_sequence) stop_button = QtWidgets.QPushButton('Stop Sequence', self._main) stop_button.setToolTip("Stop Sequence immediately") self._main.gridlayout.addWidget(stop_button, 2, 0, 1, 1) stop_button.clicked.connect(self.stop_sequence) term_button = QtWidgets.QPushButton('Terminate Sequence', self._main) term_button.setToolTip("Stop Sequence immediately") self._main.gridlayout.addWidget(term_button, 3, 0, 1, 1) term_button.clicked.connect(self.terminate_sequence) self.ht1textbox = QtWidgets.QLineEdit(self) self.ht1textbox.setText('%3i' % self.preset_temps['ht1']) self._main.gridlayout.addWidget(self.ht1textbox, 5, 0, 1, 1) ht1tempbutton = QtWidgets.QPushButton('HT1 temp:', self) ht1tempbutton.setToolTip("Enter the current HT1 preset temperature") self._main.gridlayout.addWidget(ht1tempbutton, 4, 0, 1, 1, QtCore.Qt.AlignRight) ht1tempbutton.clicked.connect(self.setht1param) self.ir301textbox = QtWidgets.QLineEdit(self) self.ir301textbox.setText('%3.1f' % self.preset_temps['ir301']) self._main.gridlayout.addWidget(self.ir301textbox, 7, 0, 1, 1) ir301tempbutton = QtWidgets.QPushButton('IR301 temp:', self) ir301tempbutton.setToolTip( "Enter the current IR301 preset temperature") self._main.gridlayout.addWidget(ir301tempbutton, 6, 0, 1, 1, QtCore.Qt.AlignRight) ir301tempbutton.clicked.connect(self.setir301param) ##matplotlib integration from: ##https://matplotlib.org/gallery/user_interfaces/embedding_in_qt_sgskip.html#sphx-glr-gallery-user-interfaces-embedding-in-qt-sgskip-py plot_box = QtWidgets.QGroupBox(self._main) plot_box.gridlayout = QtWidgets.QGridLayout() self._main.gridlayout.addWidget(plot_box, 1, 4, 12, 4) self.dynamic_canvas = FigureCanvas(Figure(figsize=(6, 5))) # self.addToolBar(QtCore.Qt.BottomToolBarArea, NavigationToolbar(self.dynamic_canvas,plot_box)) plot_box.nav = NavigationToolbar(self.dynamic_canvas, plot_box) plot_box.gridlayout.addWidget(plot_box.nav, 1, 0, 1, 1) self._dynamic_ax1, self._dynamic_ax2 = self.dynamic_canvas.figure.subplots( 2) plot_box.gridlayout.addWidget(self.dynamic_canvas, 0, 0, 1, 1) plot_box.setLayout(plot_box.gridlayout) self._main.setLayout(self._main.gridlayout)
def __init__(self, dataset): """ Construct the widget Args: dataset: xarray.Dataset """ super().__init__() main_layout = QW.QVBoxLayout(self) self.varlist = QW.QComboBox() self.xdim = QW.QComboBox() self.ydim = QW.QComboBox() header = QW.QGroupBox() header_layout = QW.QHBoxLayout(header) header_layout.addWidget(self.varlist) header_layout.addWidget(self.xdim) header_layout.addWidget(self.ydim) main_layout.addWidget(header) figure_group = QW.QGroupBox() figure_layout = QW.QHBoxLayout(figure_group) figure = Figure(tight_layout=True) figure.set_frameon(False) self.canvas = FigureCanvas(figure) self.canvas.setStyleSheet("background-color:transparent;") self.axis = self.canvas.figure.subplots() self.colorbar = ColorBarWidget() figure_layout.addWidget(self.canvas) figure_layout.addWidget(self.colorbar) main_layout.addWidget(figure_group) #: Dataset being inspected self.dataset = dataset # Setup list of variables, further setup is done by change_variable() classes = classify_vars(dataset) variables = sorted( [v for v in classes['data'] if dataset[v].ndim >= 2]) self.varlist.addItems(variables) # Connect slots self.varlist.currentIndexChanged.connect(self.change_variable) self.xdim.activated.connect(self.change_axes) self.ydim.activated.connect(self.change_axes) self.colorbar.valueChanged.connect(self.redraw) #: Currently active variable self.variable = None #: Values for non-axis dimensions self.dims = {} dims_group = QW.QGroupBox() dims_layout = QW.QVBoxLayout(dims_group) # Create widgets for coordinates for name in self.dataset.coords: self.dims[name] = DimensionWidget(self.dataset[name]) self.dims[name].valueChanged.connect(self.redraw) dims_layout.addWidget(self.dims[name]) # Create widgets for bare dims for name in self.dataset.dims: if name not in self.dims: da = xarray.DataArray(range(self.dataset.dims[name])) self.dims[name] = DimensionWidget(da) self.dims[name].valueChanged.connect(self.redraw) dims_layout.addWidget(self.dims[name]) main_layout.addWidget(dims_group) if len(variables) > 0: self.change_variable()
def get_controls_layout(self): self.controls = QtWidgets.QGroupBox('Image controls') # min and max values self.min_label = QtWidgets.QLabel(self) self.min_label.setText('Min: ') self.min = QtWidgets.QLineEdit('{:10.7f}'.format(self.vmin), self) self.min.setToolTip('The minimum value to display') self.min.returnPressed.connect(self.update_min) self.max_label = QtWidgets.QLabel(self) self.max_label.setText('Max: ') self.max = QtWidgets.QLineEdit('{:10.7f}'.format(self.vmax), self) self.max.setToolTip('The maxmimum value to display.') self.max.returnPressed.connect(self.update_max) # RMS value self.rms = QtWidgets.QLabel(self) strrms = np.nanmedian(np.sqrt(self.qube.variance[self.channel])) self.rms.setText('RMS value: {:10.7f}'.format(strrms)) # Contour levels self.levels_label = QtWidgets.QLabel(self) self.levels_label.setText('Contour levels: ') self.levels = QtWidgets.QLineEdit(__arrtostr__(self.contours), self) self.levels.setToolTip('Contours levels to display ' + '(in terms of RMS). Should be a list of ' + 'floats separated by commas.') self.levels.returnPressed.connect(self.update_contours) # color map self.colormap_label = QtWidgets.QLabel(self) self.colormap_label.setText('Colormap: ') self.colormap = QtWidgets.QLineEdit('{}'.format(self.cmap), self) self.colormap.setToolTip('The color map to use for the display') self.colormap.returnPressed.connect(self.update_cmap) # Contour colors self.levelcolor_label = QtWidgets.QLabel(self) self.levelcolor_label.setText('Contour Color: ') self.levelcolor = QtWidgets.QLineEdit('{}'.format(self.ccolor), self) self.levelcolor.setToolTip('The color of the contours') self.levelcolor.returnPressed.connect(self.update_levelcolor) # plot mask button self.mask = QtWidgets.QCheckBox('Plot mask') self.mask.setToolTip('Plot the mask used for the fitting.') self.mask.clicked.connect(self.update_figures) # plot chi squared value self.chisq = QtWidgets.QLabel(self) self.chisq.setText('Red. Chi-Squared: ' + '{:10.7f}'.format(self.chisquared)) # create layout layout = QtWidgets.QGridLayout() layout.addWidget(self.min_label, 0, 0) layout.addWidget(self.min, 0, 1) layout.addWidget(self.max_label, 1, 0) layout.addWidget(self.max, 1, 1) layout.addWidget(self.rms, 0, 2, 1, 2) layout.addWidget(self.levels_label, 1, 2) layout.addWidget(self.levels, 1, 3) layout.addWidget(self.colormap_label, 0, 4) layout.addWidget(self.colormap, 0, 5) layout.addWidget(self.levelcolor_label, 1, 4) layout.addWidget(self.levelcolor, 1, 5) layout.addWidget(self.mask, 0, 6) layout.addWidget(self.chisq, 1, 6) self.controls.setLayout(layout)
def Init_StatusBox(self): sbox = QtWidgets.QGroupBox(self.main) self.gridlayout.addWidget(sbox, 0, 1, 10, 1) sbox.gridlayout = QtWidgets.QGridLayout() title = QtWidgets.QLabel(sbox) title.setText('Status box') sbox.gridlayout.addWidget(title, 0, 0, 1, 1, QtCore.Qt.AlignLeft) ### General status and kob box statbox = QtWidgets.QGroupBox(sbox) sbox.gridlayout.addWidget(statbox, 1, 0, 1, 1) statbox.gridlayout = QtWidgets.QGridLayout() ### Conditions OK? statlabel = QtWidgets.QLabel(statbox) statlabel.setText('Conditions') statbox.gridlayout.addWidget(statlabel, 0, 0, 1, 2, QtCore.Qt.AlignLeft) self.conds = QtWidgets.QLabel(statbox) statbox.gridlayout.addWidget(self.conds, 0, 1, 1, 1, QtCore.Qt.AlignLeft) statbox.setLayout(statbox.gridlayout) ### Which state is the software in? modlabel = QtWidgets.QLabel(statbox) modlabel.setText('Software Mode') statbox.gridlayout.addWidget(modlabel, 1, 0, 1, 1, QtCore.Qt.AlignLeft) self.auto_modus = QtWidgets.QLabel(statbox) statbox.gridlayout.addWidget(self.auto_modus, 1, 1, 1, 1, QtCore.Qt.AlignLeft) modlabel = QtWidgets.QLabel(statbox) modlabel.setText('Sequence running?') statbox.gridlayout.addWidget(modlabel, 2, 0, 1, 1, QtCore.Qt.AlignLeft) self.seq_modus = QtWidgets.QLabel(statbox) statbox.gridlayout.addWidget(self.seq_modus, 2, 1, 1, 1, QtCore.Qt.AlignLeft) statbox.setLayout(statbox.gridlayout) ### SR 80 monitor box tempbox = QtWidgets.QGroupBox(sbox) sbox.gridlayout.addWidget(tempbox, 2, 0, 1, 1) tempbox.gridlayout = QtWidgets.QGridLayout() templabel = QtWidgets.QLabel(tempbox) templabel.setText('SR80 Temperature') tempbox.gridlayout.addWidget(templabel, 1, 0, 1, 2, QtCore.Qt.AlignLeft) # self.sr80_temp = QtWidgets.QLabel(sbox) # sbox.gridlayout.addWidget(self.sr80_temp,1,1,1,1,QtCore.Qt.AlignLeft) sr80_l1 = QtWidgets.QLabel(tempbox) sr80_l1.setText('Target') tempbox.gridlayout.addWidget(sr80_l1, 2, 0, 1, 1, QtCore.Qt.AlignLeft) self.sr80_target = QtWidgets.QLabel(tempbox) tempbox.gridlayout.addWidget(self.sr80_target, 2, 1, 1, 1, QtCore.Qt.AlignLeft) sr80_l1 = QtWidgets.QLabel(tempbox) sr80_l1.setText('Reached') tempbox.gridlayout.addWidget(sr80_l1, 3, 0, 1, 1, QtCore.Qt.AlignLeft) self.sr80_reached = QtWidgets.QLabel(tempbox) tempbox.gridlayout.addWidget(self.sr80_reached, 3, 1, 1, 1, QtCore.Qt.AlignLeft) sr80_l1 = QtWidgets.QLabel(tempbox) sr80_l1.setText('Stable') tempbox.gridlayout.addWidget(sr80_l1, 4, 0, 1, 1, QtCore.Qt.AlignLeft) self.sr80_status = QtWidgets.QLabel(tempbox) tempbox.gridlayout.addWidget(self.sr80_status, 4, 1, 1, 1, QtCore.Qt.AlignLeft) tempbox.setLayout(tempbox.gridlayout) #### VR80 Monitor box v80box = QtWidgets.QGroupBox(sbox) sbox.gridlayout.addWidget(v80box, 3, 0, 1, 1) v80box.gridlayout = QtWidgets.QGridLayout() v80_label = QtWidgets.QLabel(v80box) v80_label.setText('Vertex 80') v80box.gridlayout.addWidget(v80_label, 0, 0, 1, 2, QtCore.Qt.AlignLeft) v80_l1 = QtWidgets.QLabel(v80box) v80_l1.setText('Status') v80box.gridlayout.addWidget(v80_l1, 1, 0, 1, 1, QtCore.Qt.AlignLeft) self.v80_status = QtWidgets.QLabel(v80box) v80box.gridlayout.addWidget(self.v80_status, 1, 1, 1, 1, QtCore.Qt.AlignLeft) v80_l4 = QtWidgets.QLabel(v80box) v80_l4.setText('Scans') v80box.gridlayout.addWidget(v80_l4, 2, 0, 1, 1, QtCore.Qt.AlignLeft) self.v80_scans = QtWidgets.QLabel(v80box) v80box.gridlayout.addWidget(self.v80_scans, 2, 1, 1, 1, QtCore.Qt.AlignLeft) v80_l2 = QtWidgets.QLabel(v80box) v80_l2.setText('Detector') v80box.gridlayout.addWidget(v80_l2, 3, 0, 1, 1, QtCore.Qt.AlignLeft) self.v80_detector = QtWidgets.QLabel(v80box) v80box.gridlayout.addWidget(self.v80_detector, 3, 1, 1, 1, QtCore.Qt.AlignLeft) v80_l3 = QtWidgets.QLabel(v80box) v80_l3.setText('Datafile') v80box.gridlayout.addWidget(v80_l3, 4, 0, 1, 1, QtCore.Qt.AlignLeft) self.v80_datafile = QtWidgets.QLabel(v80box) v80box.gridlayout.addWidget(self.v80_datafile, 4, 1, 1, 1, QtCore.Qt.AlignLeft) v80_pka = QtWidgets.QLabel(v80box) v80_pka.setText('Amplitude') v80box.gridlayout.addWidget(v80_pka, 5, 0, 1, 1, QtCore.Qt.AlignLeft) self.v80_pka = QtWidgets.QLabel(v80box) v80box.gridlayout.addWidget(self.v80_pka, 5, 1, 1, 1, QtCore.Qt.AlignLeft) v80box.setLayout(v80box.gridlayout) ### Hutch status hutchbox = QtWidgets.QGroupBox(sbox) sbox.gridlayout.addWidget(hutchbox, 4, 0, 1, 1) hutchbox.gridlayout = QtWidgets.QGridLayout() hutch_label = QtWidgets.QLabel(hutchbox) hutch_label.setText('Hutch') hutchbox.gridlayout.addWidget(hutch_label, 0, 0, 1, 2, QtCore.Qt.AlignLeft) hutchbox.setLayout(hutchbox.gridlayout) hutch_l1 = QtWidgets.QLabel(v80box) hutch_l1.setText('Status') hutchbox.gridlayout.addWidget(hutch_l1, 1, 0, 1, 1, QtCore.Qt.AlignLeft) self.hutch_status = QtWidgets.QLabel(hutchbox) hutchbox.gridlayout.addWidget(self.hutch_status, 1, 1, 1, 1, QtCore.Qt.AlignLeft) self.hutch_remote = QtWidgets.QLabel(hutchbox) hutchbox.gridlayout.addWidget(self.hutch_remote, 2, 1, 1, 1, QtCore.Qt.AlignLeft) sbox.setLayout(sbox.gridlayout)