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 __init__(self, data, comment="", with_margin=False, parent=None): """ Parameters ---------- data : list of (label, value) pairs The data to be edited in the form. comment : str, optional with_margin : bool, optional, default: False If False, the form elements reach to the border of the widget. This is the desired behavior if the FormWidget is used as a widget alongside with other widgets such as a QComboBox, which also do not have a margin around them. However, a margin can be desired if the FormWidget is the only widget within a container, e.g. a tab in a QTabWidget. parent : QWidget or None The parent widget. """ QtWidgets.QWidget.__init__(self, parent) self.data = copy.deepcopy(data) self.widgets = [] self.formlayout = QtWidgets.QFormLayout(self) if not with_margin: self.formlayout.setContentsMargins(0, 0, 0, 0) if comment: self.formlayout.addRow(QtWidgets.QLabel(comment)) self.formlayout.addRow(QtWidgets.QLabel(" "))
def __init__(self, parent=None): super(Page3, self).__init__(parent) integerValidator = QtGui.QIntValidator(0, 10, self) coordLabel = QtWidgets.QLabel('Coordinate File:') self.coordLine = QtWidgets.QLineEdit() coordBtn = QtWidgets.QPushButton('File', self) coordBtn.clicked.connect(self.getCoordfile) self.registerField('coordFile*', self.coordLine) popLabel = QtWidgets.QLabel('Population File:') self.popLine = QtWidgets.QLineEdit() popBtn = QtWidgets.QPushButton('File', self) popBtn.clicked.connect(self.getPopfile) self.registerField('popFile*', self.popLine) grid = QtWidgets.QGridLayout() grid.setSpacing(10) grid.addWidget(coordLabel, 1, 0) grid.addWidget(self.coordLine, 1, 1) grid.addWidget(coordBtn, 1, 2) grid.addWidget(popLabel, 2, 0) grid.addWidget(self.popLine, 2, 1) grid.addWidget(popBtn, 2, 2) self.setLayout(grid)
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 __init__(self, parent, label, accessor, sense_ohms=0.1, disabled=False): super().__init__(parent) self.accessor = accessor self.label = label self.sense_ohms = sense_ohms self.disabled = disabled layout = QtWidgets.QVBoxLayout(self) lbl = QtWidgets.QLabel(self.label) lbl.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter) lbl.setStyleSheet('QLabel { font-weight: bold; color: #93a1a1; } ') layout.addWidget(lbl) sub = QtWidgets.QWidget() sub_layout = QtWidgets.QHBoxLayout(sub) self.V = QtWidgets.QLabel('nan V') self.V.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.V.setStyleSheet('QLabel { font-weight: bold; color: #268bd2; } ') sub_layout.addWidget(self.V) self.I = QtWidgets.QLabel('nan mA') self.I.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.I.setStyleSheet('QLabel { font-weight: bold; color: #6c71c4; } ') sub_layout.addWidget(self.I) layout.addWidget(sub)
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 __init__(self, parent=None, line=None): super(CurvePropertiesDialog, self).__init__(parent) self.line = line #labels self._label_color = QtWidgets.QLabel('Color') self._label_symbol = QtWidgets.QLabel('Symbol') #text inputs self._edit_color = QtWidgets.QLineEdit() self._edit_symbol = QtWidgets.QLineEdit() #buttons self._btn_ok = QtWidgets.QPushButton('OK') self._btn_cancel = QtWidgets.QPushButton('Cancel') #layout grid = QtWidgets.QGridLayout() self.setLayout(grid) grid.addWidget(self._label_color, 0, 0) grid.addWidget(self._edit_color, 0, 1) grid.addWidget(self._label_symbol, 1, 0) grid.addWidget(self._edit_symbol, 1, 1) grid.addWidget(self._btn_ok, 2, 0) grid.addWidget(self._btn_cancel, 2, 1) #connections self._btn_ok.clicked.connect(self.process_inputs) self._btn_cancel.clicked.connect(self.close) self.update_from_line(self.line)
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 __init__(self, data, comment="", parent=None): QtWidgets.QWidget.__init__(self, parent) self.data = copy.deepcopy(data) self.widgets = [] self.formlayout = QtWidgets.QFormLayout(self) if comment: self.formlayout.addRow(QtWidgets.QLabel(comment)) self.formlayout.addRow(QtWidgets.QLabel(" "))
def __init__(self, l, r, u, d, parent=None): """""" QtWidgets.QDialog.__init__(self, parent) self.setWindowTitle('Set Heatmap Domain') self.setWindowIcon(QtGui.QIcon('kiwi.png')) self.setMinimumWidth(400) self.header = QtWidgets.QLabel("All distances are relative to the array center.") self.leftLabel = QtWidgets.QLabel("Left/West:") self.lledit = QtWidgets.QLineEdit(self) self.lledit.setText(str(l)) self.rightLabel = QtWidgets.QLabel("Right/East:") self.rledit = QtWidgets.QLineEdit(self) self.rledit.setText(str(r)) self.upLabel = QtWidgets.QLabel("Up/North:") self.uledit = QtWidgets.QLineEdit(self) self.uledit.setText(str(u)) self.downLabel = QtWidgets.QLabel("Down/South:") self.dledit = QtWidgets.QLineEdit(self) self.dledit.setText(str(d)) self.activate = QtWidgets.QPushButton("Set") Box = QtWidgets.QVBoxLayout() Box.addWidget(self.header) left = QtWidgets.QHBoxLayout() left.addWidget(self.leftLabel) left.addWidget(self.lledit) right = QtWidgets.QHBoxLayout() right.addWidget(self.rightLabel) right.addWidget(self.rledit) up = QtWidgets.QHBoxLayout() up.addWidget(self.upLabel) up.addWidget(self.uledit) down = QtWidgets.QHBoxLayout() down.addWidget(self.downLabel) down.addWidget(self.dledit) Box.addLayout(left) Box.addLayout(right) Box.addLayout(up) Box.addLayout(down) Box.addWidget(self.activate) # Now put everything into the frame self.setLayout(Box)
def __init__(self, data, comment="", parent=None): QtWidgets.QWidget.__init__(self, parent) self.data = copy.deepcopy(data) self.widgets = [] self.formlayout = QtWidgets.QFormLayout(self) if comment: self.formlayout.addRow(QtWidgets.QLabel(comment)) self.formlayout.addRow(QtWidgets.QLabel(" ")) if DEBUG: print("\n"+("*"*80)) print("DATA:", self.data) print("*"*80) print("COMMENT:", comment) print("*"*80)
def __init__(self, parent=None): super(Page1, self).__init__(parent) integerValidator = QtGui.QIntValidator(0, 100, self) coordLabel = QtWidgets.QLabel('Coordinate File:') self.coordLine = QtWidgets.QLineEdit() coordBtn = QtWidgets.QPushButton('File', self) coordBtn.clicked.connect(self.getCoordfile) self.registerField('coordFile*', self.coordLine) popLabel = QtWidgets.QLabel('Population File:') self.popLine = QtWidgets.QLineEdit() popBtn = QtWidgets.QPushButton('File', self) popBtn.clicked.connect(self.getPopfile) self.registerField('popFile*', self.popLine) dataLabel = QtWidgets.QLabel('Data Directory:') self.dataLine = QtWidgets.QLineEdit() dataBtn = QtWidgets.QPushButton('File', self) dataBtn.clicked.connect(self.getDir) self.registerField('dataDir*', self.dataLine) allelesLabel = QtWidgets.QLabel('Number of alleles:') self.allelesLine = QtWidgets.QLineEdit() self.allelesLine.setValidator(integerValidator) self.registerField('alleleCount*', self.allelesLine) groupsLabel = QtWidgets.QLabel('Number of Groups:') self.groupsLine = QtWidgets.QLineEdit() self.groupsLine.setValidator(integerValidator) self.registerField('groupCount*', self.groupsLine) grid = QtWidgets.QGridLayout() grid.setSpacing(10) grid.addWidget(coordLabel, 1, 0) grid.addWidget(self.coordLine, 1, 1) grid.addWidget(coordBtn, 1, 2) grid.addWidget(popLabel, 2, 0) grid.addWidget(self.popLine, 2, 1) grid.addWidget(popBtn, 2, 2) grid.addWidget(dataLabel, 3, 0) grid.addWidget(self.dataLine, 3, 1) grid.addWidget(dataBtn, 3, 2) grid.addWidget(allelesLabel, 4, 0) grid.addWidget(self.allelesLine, 4, 1) grid.addWidget(groupsLabel, 5, 0) grid.addWidget(self.groupsLine, 5, 1) self.setLayout(grid)
def __init__(self, dimension): """ Construct the widget Args: dimension: xarray.DataArray """ super().__init__() main_layout = QW.QHBoxLayout(self) #: The dimension represented by this widget self.dimension = dimension self.title = QW.QLabel(dimension.name) self.textbox = QW.QLineEdit() self.slider = QW.QSlider(orientation=QtCore.Qt.Horizontal) self.slider.setMinimum(0) self.slider.setMaximum(dimension.size - 1) self.slider.valueChanged.connect(self._update_from_slider) self.textbox.returnPressed.connect(self._update_from_value) self.slider.setValue(0) self.textbox.setText(str(self.dimension[0].values)) main_layout.addWidget(self.title) main_layout.addWidget(self.textbox) main_layout.addWidget(self.slider)
def build_progress_bar(fig, lastframe, height): vbox = QtWidgets.QVBoxLayout() fig.canvas.setLayout(vbox) width = int(fig.bbox.height * height) bar = QtGui.QSlider(QtCore.Qt.Horizontal) bar.setRange(0, lastframe) bar.setSingleStep(1) bar.setMinimumSize(QtCore.QSize(0, width)) # Add an auto-updating label for the slider value = QtWidgets.QLabel('0 of %d' % lastframe) value.setMinimumSize(QtCore.QSize(0, width)) value.connect(bar, QtCore.SIGNAL('valueChanged(int)'), lambda frame: value.setText("%d of %d" % (frame, lastframe))) hbox = QtWidgets.QHBoxLayout() hbox.addWidget(bar) hbox.addWidget(value) # This spacer will help force the slider down to the bottom of the canvas vspace = QtGui.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) vbox.addItem(vspace) vbox.addLayout(hbox) return bar
def __init__(self, name, label, cmap, parent=None): super().__init__(parent) self.setObjectName(name) self.layout = QtWidgets.QVBoxLayout(self) self.layout.setAlignment(Qt.AlignLeft) self.label = QtWidgets.QLabel(label) self.label.setStyleSheet("QLabel { font-size: 10px; }") self.b = QtWidgets.QCheckBox("Add opacity point: ", self) self.b.stateChanged.connect(self.clickBox) self.b.setLayoutDirection(Qt.RightToLeft) nF = QtWidgets.QFrame() layout1 = QtWidgets.QHBoxLayout(nF) layout1.setContentsMargins(0, 0, 0, 0) layout1.setAlignment(Qt.AlignLeft) layout1.addWidget(self.b) layout1.addWidget(self.setup_cmap_frame(cmap)) self.layout.addWidget(self.label) self.layout.addWidget(nF) # Set shape of this QWidget self.setFrameShape(QtWidgets.QFrame.StyledPanel) self.setFrameShadow(QtWidgets.QFrame.Raised)
def __init__(self, db, fig_dispatch, text_dispatch, result_dispatch, *, max_results=100): self.db = db self._hvw = HeaderViewerWidget(fig_dispatch, text_dispatch) self.fig_dispatch = fig_dispatch self.text_dispatch = text_dispatch self.result_dispatch = result_dispatch self.max_results = max_results self._results_summary = QtWidgets.QLabel() self._results = QtWidgets.QListWidget() self._results.currentItemChanged.connect( self._on_results_selection_changed) self._search_bar = QtWidgets.QLineEdit() self._search_bar.textChanged.connect(self._on_search_text_changed) self.widget = QtWidgets.QWidget() layout = QtWidgets.QVBoxLayout() sublayout = QtWidgets.QHBoxLayout() results_pane = QtWidgets.QVBoxLayout() results_pane.addWidget(self._results_summary) results_pane.addWidget(self._results) layout.addWidget(self._search_bar) layout.addLayout(sublayout) sublayout.addLayout(results_pane) sublayout.addWidget(self._hvw.widget) self.widget.setLayout(layout) self.search()
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 __init__(self, parent, item_model): super().__init__(parent) self.item_model = item_model self.item_model.dataChanged.connect(self.update_stats) self.item_model.rowsInserted.connect(self.update_stats) self.item_model.rowsRemoved.connect(self.update_stats) self.count = QtWidgets.QLabel() self.images_remaining = QtWidgets.QLabel() self.update_stats() self.layout = QtWidgets.QFormLayout(self) self.layout.addRow(QtWidgets.QLabel("Point count:"), self.count) self.layout.addRow(QtWidgets.QLabel("Pts. w/o an image:"), self.images_remaining) self.setLayout(self.layout)
def setup_marking_label(self): marking_label = QtWidgets.QLabel('Current label-mode: ?') marking_label.setAlignment(Qt.AlignCenter) marking_label.setSizePolicy( QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.MinimumExpanding, ) return marking_label
def __init__(self, parent=None): super(StartP, self).__init__(parent) integerValidator = QtGui.QIntValidator(0, 300, self) dataLabel = QtWidgets.QLabel('Data Directory:') self.dataLine = QtWidgets.QLineEdit() dataBtn = QtWidgets.QPushButton('File', self) dataBtn.clicked.connect(self.getDir) self.registerField('dataDir*', self.dataLine) allelesLabel = QtWidgets.QLabel('Number of alleles:') self.allelesLine = QtWidgets.QLineEdit() self.allelesLine.setValidator(integerValidator) self.registerField('alleleCount*', self.allelesLine) groupsLabel = QtWidgets.QLabel('Number of Groups:') self.groupsLine = QtWidgets.QLineEdit() self.groupsLine.setValidator(integerValidator) self.registerField('groupCount*', self.groupsLine) self.b1 = QtWidgets.QCheckBox("Females") self.b1.setChecked(False) self.registerField('females', self.b1) comboLabel = QtWidgets.QLabel('Graphic Type:') self.combo = QtWidgets.QComboBox(self) self.combo.addItem('Allele Counts') self.combo.addItem('Allele Heatmap') self.combo.addItem('Allele Stack') self.combo.addItem('Allele Geo-Map') self.registerField('graphic', self.combo) grid = QtWidgets.QGridLayout() grid.setSpacing(10) grid.addWidget(dataLabel, 1, 0) grid.addWidget(self.dataLine, 1, 1) grid.addWidget(dataBtn, 1, 2) grid.addWidget(allelesLabel, 2, 0) grid.addWidget(self.allelesLine, 2, 1) grid.addWidget(groupsLabel, 3, 0) grid.addWidget(self.groupsLine, 3, 1) grid.addWidget(self.b1, 5, 1) grid.addWidget(comboLabel, 4, 0) grid.addWidget(self.combo, 4, 1) self.setLayout(grid)
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 __init__(self, entries): super().__init__() self.entries = entries self.current_entry = -1 self.current_thumbnail = -1 event_filter = EventFilter(self) self.installEventFilter(event_filter) # The list of files on the left-hand side. self.filelist = QtWidgets.QListWidget() self.filelist.setMinimumWidth(400) for entry in entries: self.filelist.addItem(entry.display) self.filelist.currentRowChanged.connect(self.set_entry) thumbnails_box = QtWidgets.QWidget() thumbnails_layout = QtWidgets.QVBoxLayout() self.thumbnails = [] for i, name in enumerate(('test', 'expected', 'diff')): thumbnail = Thumbnail(self, i, name) thumbnails_layout.addWidget(thumbnail) self.thumbnails.append(thumbnail) thumbnails_box.setLayout(thumbnails_layout) images_layout = QtWidgets.QVBoxLayout() images_box = QtWidgets.QWidget() self.image_display = QtWidgets.QLabel() self.image_display.setAlignment( _enum('QtCore.Qt.AlignmentFlag').AlignHCenter | _enum('QtCore.Qt.AlignmentFlag').AlignVCenter) self.image_display.setMinimumSize(800, 600) images_layout.addWidget(self.image_display, 6) images_box.setLayout(images_layout) buttons_box = QtWidgets.QWidget() buttons_layout = QtWidgets.QHBoxLayout() accept_button = QtWidgets.QPushButton("Accept (A)") accept_button.clicked.connect(self.accept_test) buttons_layout.addWidget(accept_button) reject_button = QtWidgets.QPushButton("Reject (R)") reject_button.clicked.connect(self.reject_test) buttons_layout.addWidget(reject_button) buttons_box.setLayout(buttons_layout) images_layout.addWidget(buttons_box) main_layout = QtWidgets.QHBoxLayout() main_layout.addWidget(self.filelist, 1) main_layout.addWidget(thumbnails_box, 1) main_layout.addWidget(images_box, 3) self.setLayout(main_layout) self.setWindowTitle("matplotlib test triager") self.set_entry(0)
def __init__(self, parent, index, name): super().__init__() self.parent = parent self.index = index layout = QtWidgets.QVBoxLayout() label = QtWidgets.QLabel(name) label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) layout.addWidget(label, 0) self.image = QtWidgets.QLabel() self.image.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) self.image.setMinimumSize(800 / 3, 500 / 3) layout.addWidget(self.image) self.setLayout(layout)
def add_QDateTimeEdit(self, spec): widget = QtWidgets.QDateTimeEdit(spec.get('default', datetime.utcnow())) self.fields[spec['name']] = widget widget.setTime(QtCore.QTime(0, 0, 0)) widget.setCalendarPopup(True) label_text = spec.get('label', spec['name']) self.layout.addWidget(QtWidgets.QLabel(label_text)) self.layout.addWidget(widget)
def initializePage(self): groups = int(self.field('groupCount')) alleles = int(self.field('alleleCount')) integerValidator = QtGui.QIntValidator(0, 10, self) vbox = self.layout() for i in range(groups): hbox = QtWidgets.QHBoxLayout() glabel = QtWidgets.QLabel("group " + str(i + 1) + ":") for j in range(alleles): label = QtWidgets.QLabel(str(j + 1) + ":") line = QtWidgets.QLineEdit() line.setValidator(integerValidator) line.setText('0') self.registerField(str(i) + '-' + str(j), line) hbox.addWidget(label) hbox.addWidget(line) vbox.addWidget(glabel) vbox.addLayout(hbox)
def __init__(self, parent): super().__init__(parent) self.api = OscApi("http://192.168.1.1", timeout=5) self.status = QtWidgets.QLabel("Camera: OK") self.layout = QtWidgets.QVBoxLayout(self) self.layout.addWidget(self.status) self.setLayout(self.layout)
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, parent, label, accessor): super().__init__(parent) self.accessor = accessor self.label = label layout = QtWidgets.QVBoxLayout(self) lbl = QtWidgets.QLabel(self.label) lbl.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter) lbl.setStyleSheet('QLabel { font-weight: bold; color: #93a1a1; } ') layout.addWidget(lbl) sub = QtWidgets.QWidget() sub_layout = QtWidgets.QHBoxLayout(sub) self.T = QtWidgets.QLabel('nan C') self.T.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter) self.T.setStyleSheet('QLabel { font-weight: bold; color: #2aa198; } ') sub_layout.addWidget(self.T) layout.addWidget(sub)
def add_QLineEdit(self, spec): widget = QtWidgets.QLineEdit() self.fields[spec['name']] = widget label_text = spec.get('label', spec['name']) self.layout.addWidget(QtWidgets.QLabel(label_text)) self.layout.addWidget(widget) if 'default' in spec: widget.setText(spec['default']) if 'autocomplete-list' in spec: widget.setCompleter(QtWidgets.QCompleter( spec['autocomplete-list']))