def __init__( self, func=None, func_args=[], func_kwargs={}, margin=30, vert_spacing=10, current_layout="TopBottomLayout", description="", single_pass: bool = False, *args, **kwargs ): super().__init__() # static definitions self.func = func self.args = func_args self.kwargs = func_kwargs self.widget_list = [] self.margin = margin self.vert_spacing = vert_spacing self.single_pass = single_pass self.stdout = sys.stdout self.stderr = sys.stderr self.Current_Layout = layouts.Layout_Dict["TopBottomLayout"] if current_layout in layouts.Layout_Dict: self.Current_Layout = layouts.Layout_Dict[current_layout](self) # Initiallize self.canvas = QWidget() self.canvas.setObjectName("canvas") # create a scroll bar self.widget_scroll = QScrollArea(self) self.widget_scroll.setObjectName("widget_scroll") # use a QFormLayout to place widgets self.canvas_layout = QFormLayout() self.canvas_layout.setObjectName("canvas_layout") # set canvas_layout self.canvas_layout.setMargin(self.margin) self.canvas_layout.setSpacing(self.vert_spacing) self.canvas_layout.setRowWrapPolicy(self.canvas_layout.WrapAllRows) # default description is func.__doc__ self.description = QLabel( self.getDescription(description) ) # doesn't need to scroll self.description.setParent(self) self.description.setWordWrap(True) self.description.setTextFormat(Qt.MarkdownText) self.description.setOpenExternalLinks(True) # create a Run button to excute the function self.run_button = QPushButton("&Run", self) self.run_button.clicked.connect(self.Run) self.run_button.adjustSize() # allow the user to run the func multiple times to test output # but only the last return is delivered (as a confirmed run) self.run_thread = RunThread(self.func, self.args, self.kwargs) self.run_thread.finished.connect(self.Done)
def init_meta_tab(self): # Center panels ------------------------------------------------------- self.groups_list = [] # Left-side panel: forms self.btn_load_meta = QPushButton('Load metafile') self.btn_load_meta.setIcon(self.style().standardIcon( QStyle.SP_ArrowDown)) self.btn_load_meta.clicked.connect( lambda: self.load_meta_file(filename=None)) self.btn_load_meta.setToolTip( "The YAML file with metadata for this conversion.\n" "You can customize the metadata in the forms below.") self.btn_save_meta = QPushButton('Save metafile') self.btn_save_meta.setIcon(self.style().standardIcon( QStyle.SP_DriveFDIcon)) self.btn_save_meta.clicked.connect(self.save_meta_file) self.btn_run_conversion = QPushButton('Run conversion') self.btn_run_conversion.setIcon(self.style().standardIcon( QStyle.SP_MediaPlay)) self.btn_run_conversion.clicked.connect(self.run_conversion) self.btn_form_editor = QPushButton('Form -> Editor') self.btn_form_editor.clicked.connect(self.form_to_editor) self.lbl_nwb_file = QLabel('Output nwb file:') self.lbl_nwb_file.setToolTip( "Path to the NWB file that will be created.") self.lin_nwb_file = QLineEdit('') self.btn_nwb_file = QPushButton() self.btn_nwb_file.setIcon(self.style().standardIcon( QStyle.SP_DialogOpenButton)) self.btn_nwb_file.clicked.connect(self.load_nwb_file) l_grid1 = QGridLayout() l_grid1.setColumnStretch(3, 1) l_grid1.addWidget(self.btn_load_meta, 0, 0, 1, 1) l_grid1.addWidget(self.btn_save_meta, 0, 1, 1, 1) l_grid1.addWidget(self.btn_run_conversion, 0, 2, 1, 1) l_grid1.addWidget(QLabel(), 0, 3, 1, 1) l_grid1.addWidget(self.btn_form_editor, 0, 4, 1, 2) l_grid1.addWidget(self.lbl_nwb_file, 1, 0, 1, 1) l_grid1.addWidget(self.lin_nwb_file, 1, 1, 1, 3) l_grid1.addWidget(self.btn_nwb_file, 1, 4, 1, 1) # Adds custom files/dir paths fields if len(self.source_paths.keys()) == 0: self.lbl_source_file = QLabel('source files:') self.lin_source_file = QLineEdit('') self.btn_source_file = QPushButton() self.btn_source_file.setIcon(self.style().standardIcon( QStyle.SP_DialogOpenButton)) self.btn_source_file.clicked.connect(self.load_source_files) l_grid1.addWidget(self.lbl_source_file, 3, 0, 1, 1) l_grid1.addWidget(self.lin_source_file, 3, 1, 1, 3) l_grid1.addWidget(self.btn_source_file, 3, 4, 1, 1) else: self.group_source_paths = QGroupBox('Source paths') self.grid_source = QGridLayout() self.grid_source.setColumnStretch(3, 1) ii = -1 for k, v in self.source_paths.items(): ii += 1 lbl_src = QLabel(k + ':') setattr(self, 'lbl_src_' + str(ii), lbl_src) lin_src = QLineEdit('') setattr(self, 'lin_src_' + str(ii), lin_src) btn_src = QPushButton() btn_src.setIcon(self.style().standardIcon( QStyle.SP_DialogOpenButton)) setattr(self, 'btn_src_' + str(ii), btn_src) if v['type'] == 'file': btn_src.clicked.connect( (lambda x: lambda: self.load_source_files(x[0], x[1]))( [ii, k])) else: btn_src.clicked.connect( (lambda x: lambda: self.load_source_dir(x[0], x[1]))( [ii, k])) self.grid_source.addWidget(lbl_src, ii, 0, 1, 1) self.grid_source.addWidget(lin_src, ii, 1, 1, 3) self.grid_source.addWidget(btn_src, ii, 4, 1, 1) self.group_source_paths.setLayout(self.grid_source) l_grid1.addWidget(self.group_source_paths, 3, 0, 1, 6) # Adds custom kwargs checkboxes if len(self.kwargs_fields.keys()) > 0: self.group_kwargs = QGroupBox('KWARGS') self.grid_kwargs = QGridLayout() self.grid_kwargs.setColumnStretch(4, 1) ii = -1 for k, v in self.kwargs_fields.items(): ii += 1 chk_kwargs = QCheckBox(k) chk_kwargs.setChecked(v) chk_kwargs.clicked.connect( (lambda x: lambda: self.update_kwargs(x[0], x[1]))([ii, k])) setattr(self, 'chk_kwargs_' + str(ii), chk_kwargs) self.grid_kwargs.addWidget(chk_kwargs, ii // 4, ii % 4, 1, 1) self.group_kwargs.setLayout(self.grid_kwargs) l_grid1.addWidget(self.group_kwargs, 4, 0, 1, 6) self.l_vbox1 = QVBoxLayout() self.l_vbox1.addStretch() scroll_aux = QWidget() scroll_aux.setLayout(self.l_vbox1) l_scroll = QScrollArea() l_scroll.setWidget(scroll_aux) l_scroll.setWidgetResizable(True) self.l_vbox2 = QVBoxLayout() self.l_vbox2.addLayout(l_grid1) self.l_vbox2.addWidget(l_scroll) # Right-side panel # Metadata text editor_label = QLabel('Metafile preview:') r_grid1 = QGridLayout() r_grid1.setColumnStretch(1, 1) r_grid1.addWidget(editor_label, 0, 0, 1, 1) r_grid1.addWidget(QLabel(), 0, 1, 1, 1) self.editor = QTextEdit() r_vbox1 = QVBoxLayout() r_vbox1.addLayout(r_grid1) r_vbox1.addWidget(self.editor) # Logger log_label = QLabel('Log:') r_grid2 = QGridLayout() r_grid2.setColumnStretch(1, 1) r_grid2.addWidget(log_label, 0, 0, 1, 1) r_grid2.addWidget(QLabel(), 0, 1, 1, 1) self.logger = QTextEdit() self.logger.setReadOnly(True) r_vbox2 = QVBoxLayout() r_vbox2.addLayout(r_grid2) r_vbox2.addWidget(self.logger) r_vsplitter = QSplitter(QtCore.Qt.Vertical) ru_w = QWidget() ru_w.setLayout(r_vbox1) rb_w = QWidget() rb_w.setLayout(r_vbox2) r_vsplitter.addWidget(ru_w) r_vsplitter.addWidget(rb_w) # Metadata/conversion tab Layout self.left_w = QWidget() self.left_w.setLayout(self.l_vbox2) self.splitter = QSplitter(QtCore.Qt.Horizontal) self.splitter.addWidget(self.left_w) self.splitter.addWidget(r_vsplitter) self.metadata_layout = QVBoxLayout() self.metadata_layout.addWidget(self.splitter) self.tab_metadata = QWidget() self.tab_metadata.setLayout(self.metadata_layout) self.tabs.addTab(self.tab_metadata, 'Metadata/Conversion') # Background color p = self.palette() p.setColor(self.backgroundRole(), QtCore.Qt.white) self.setPalette(p)
def __init__(self, filename, image, parent=None): super(ComparisonWidget, self).__init__(parent) load_button = QPushButton(self.tr('Load reference image...')) self.comp_label = QLabel(self.tr('Comparison:')) self.normal_radio = QRadioButton(self.tr('Normal')) self.normal_radio.setToolTip(self.tr('Show reference (raw pixels)')) self.normal_radio.setChecked(True) self.difference_radio = QRadioButton(self.tr('Difference')) self.difference_radio.setToolTip( self.tr('Show evidence/reference difference')) self.ssim_radio = QRadioButton(self.tr('SSIM Map')) self.ssim_radio.setToolTip(self.tr('Structure similarity quality map')) self.butter_radio = QRadioButton(self.tr('Butteraugli')) self.butter_radio.setToolTip( self.tr('Butteraugli spatial changes heatmap')) self.gray_check = QCheckBox(self.tr('Grayscale')) self.gray_check.setToolTip(self.tr('Show desaturated output')) self.equalize_check = QCheckBox(self.tr('Equalized')) self.equalize_check.setToolTip(self.tr('Apply histogram equalization')) self.last_radio = self.normal_radio self.metric_button = QPushButton(self.tr('Compute')) self.metric_button.setToolTip( self.tr('Image quality assessment metrics')) self.evidence = image self.reference = self.difference = self.ssim_map = self.butter_map = None basename = os.path.basename(filename) self.evidence_viewer = ImageViewer( self.evidence, None, self.tr('Evidence: {}'.format(basename))) self.reference_viewer = ImageViewer(np.full_like(self.evidence, 127), None, self.tr('Reference')) self.table_widget = QTableWidget(21, 3) self.table_widget.setHorizontalHeaderLabels( [self.tr('Metric'), self.tr('Value'), self.tr('Better')]) self.table_widget.setItem(0, 0, QTableWidgetItem(self.tr('RMSE'))) self.table_widget.setItem( 0, 2, QTableWidgetItem(QIcon('icons/low.svg'), '(0)')) self.table_widget.item(0, 0).setToolTip( self. tr('Root Mean Square Error (RMSE) is commonly used to compare \n' 'the difference between the reference and evidence images \n' 'by directly computing the variation in pixel values. \n' 'The combined image is close to the reference image when \n' 'RMSE value is zero. RMSE is a good indicator of the spectral \n' 'quality of the reference image.')) self.table_widget.setItem(1, 0, QTableWidgetItem(self.tr('SAM'))) self.table_widget.setItem( 1, 2, QTableWidgetItem(QIcon('icons/low.svg'), '(0)')) self.table_widget.item(1, 0).setToolTip( self. tr('It computes the spectral angle between the pixel, vector of the \n' 'evidence image and reference image. It is worked out in either \n' 'degrees or radians. It is performed on a pixel-by-pixel base. \n' 'A SAM equal to zero denotes the absence of spectral distortion.' )) self.table_widget.setItem(2, 0, QTableWidgetItem(self.tr('ERGAS'))) self.table_widget.setItem( 2, 2, QTableWidgetItem(QIcon('icons/low.svg'), '(0)')) self.table_widget.item(2, 0).setToolTip( self. tr('It is used to compute the quality of reference image in terms \n' 'of normalized average error of each band of the reference image. \n' 'Increase in the value of ERGAS indicates distortion in the \n' 'reference image, lower value of ERGAS indicates that it is \n' 'similar to the reference image.')) self.table_widget.setItem(3, 0, QTableWidgetItem(self.tr('MB'))) self.table_widget.setItem( 3, 2, QTableWidgetItem(QIcon('icons/low.svg'), '(0)')) self.table_widget.item(3, 0).setToolTip( self. tr('Mean Bias is the difference between the mean of the evidence \n' 'image and reference image. The ideal value is zero and indicates \n' 'that the evidence and reference images are similar. Mean value \n' 'refers to the grey level of pixels in an image.')) self.table_widget.setItem(4, 0, QTableWidgetItem(self.tr('PFE'))) self.table_widget.setItem( 4, 2, QTableWidgetItem(QIcon('icons/low.svg'), '(0)')) self.table_widget.item(4, 0).setToolTip( self. tr('It computes the norm of the difference between the corresponding \n' 'pixels of the reference and fused image to the norm of the reference \n' 'image. When the calculated value is zero, it indicates that both the \n' 'reference and fused images are similar and value will be increased \n' 'when the merged image is not similar to the reference image.')) self.table_widget.setItem(5, 0, QTableWidgetItem(self.tr('PSNR'))) self.table_widget.setItem( 5, 2, QTableWidgetItem(QIcon('icons/high.svg'), '(+' + u'\u221e' + ')')) self.table_widget.item(5, 0).setToolTip( self. tr('It is widely used metric it is computed by the number of gray levels \n' 'in the image divided by the corresponding pixels in the evidence and \n' 'the reference images. When the value is high, both images are similar.' )) self.table_widget.setItem(6, 0, QTableWidgetItem(self.tr('PSNR-B'))) self.table_widget.setItem( 6, 2, QTableWidgetItem(QIcon('icons/high.svg'), '(+' + u'\u221e' + ')')) self.table_widget.item(6, 0).setToolTip( self.tr('PSNR with Blocking Effect Factor.')) self.table_widget.setItem(7, 0, QTableWidgetItem(self.tr('SSIM'))) self.table_widget.setItem( 7, 2, QTableWidgetItem(QIcon('icons/high.svg'), '(1)')) self.table_widget.item(7, 0).setToolTip( self. tr('SSIM is used to compare the local patterns of pixel intensities between \n' ' the reference and fused images. The range varies between -1 to 1. \n' 'The value 1 indicates the reference and fused images are similar.' )) self.table_widget.setItem(8, 0, QTableWidgetItem(self.tr('MS-SSIM'))) self.table_widget.setItem( 8, 2, QTableWidgetItem(QIcon('icons/high.svg'), '(1)')) self.table_widget.item(8, 0).setToolTip( self.tr('Multiscale version of SSIM.')) self.table_widget.setItem(9, 0, QTableWidgetItem(self.tr('RASE'))) self.table_widget.setItem( 9, 2, QTableWidgetItem(QIcon('icons/low.svg'), '(0)')) self.table_widget.item(9, 0).setToolTip( self.tr('Relative average spectral error')) self.table_widget.setItem(10, 0, QTableWidgetItem(self.tr('SCC'))) self.table_widget.setItem( 10, 2, QTableWidgetItem(QIcon('icons/high.svg'), '(1)')) self.table_widget.item(10, 0).setToolTip( self.tr('Spatial Correlation Coefficient')) self.table_widget.setItem(11, 0, QTableWidgetItem(self.tr('UQI'))) self.table_widget.setItem( 11, 2, QTableWidgetItem(QIcon('icons/high.svg'), '(1)')) self.table_widget.item(11, 0).setToolTip( self.tr('Universal Image Quality Index')) self.table_widget.setItem(12, 0, QTableWidgetItem(self.tr('VIF-P'))) self.table_widget.setItem( 12, 2, QTableWidgetItem(QIcon('icons/high.svg'), '(1)')) self.table_widget.item(12, 0).setToolTip( self.tr('Pixel-based Visual Information Fidelity')) self.table_widget.setItem(13, 0, QTableWidgetItem(self.tr('SSIMulacra'))) self.table_widget.setItem( 13, 2, QTableWidgetItem(QIcon('icons/low.svg'), '(0)')) self.table_widget.item(13, 0).setToolTip( self.tr('Structural SIMilarity Unveiling Local ' 'And Compression Related Artifacts')) self.table_widget.setItem(14, 0, QTableWidgetItem(self.tr('Butteraugli'))) self.table_widget.setItem( 14, 2, QTableWidgetItem(QIcon('icons/low.svg'), '(0)')) self.table_widget.item(14, 0).setToolTip( self.tr('Estimate psychovisual error')) self.table_widget.setItem(15, 0, QTableWidgetItem(self.tr('Correlation'))) self.table_widget.setItem( 15, 2, QTableWidgetItem(QIcon('icons/high.svg'), '(1)')) self.table_widget.item(15, 0).setToolTip(self.tr('Histogram correlation')) self.table_widget.setItem(16, 0, QTableWidgetItem(self.tr('Chi-Square'))) self.table_widget.setItem( 16, 2, QTableWidgetItem(QIcon('icons/low.svg'), '(0)')) self.table_widget.item(16, 0).setToolTip(self.tr('Histogram Chi-Square')) self.table_widget.setItem(17, 0, QTableWidgetItem(self.tr('Chi-Square 2'))) self.table_widget.setItem( 17, 2, QTableWidgetItem(QIcon('icons/low.svg'), '(0)')) self.table_widget.item(17, 0).setToolTip(self.tr('Alternative Chi-Square')) self.table_widget.setItem(18, 0, QTableWidgetItem(self.tr('Intersection'))) self.table_widget.setItem( 18, 2, QTableWidgetItem(QIcon('icons/high.svg'), '(+' + u'\u221e' + ')')) self.table_widget.item(18, 0).setToolTip(self.tr('Histogram intersection')) self.table_widget.setItem(19, 0, QTableWidgetItem(self.tr('Hellinger'))) self.table_widget.setItem( 19, 2, QTableWidgetItem(QIcon('icons/low.svg'), '(0)')) self.table_widget.item(19, 0).setToolTip( self.tr('Histogram Hellinger distance')) self.table_widget.setItem(20, 0, QTableWidgetItem(self.tr('Divergence'))) self.table_widget.setItem( 20, 2, QTableWidgetItem(QIcon('icons/low.svg'), '(0)')) self.table_widget.item(20, 0).setToolTip( self.tr('Kullback-Leibler divergence')) for i in range(self.table_widget.rowCount()): modify_font(self.table_widget.item(i, 0), bold=True) self.table_widget.setSelectionMode(QAbstractItemView.SingleSelection) self.table_widget.setEditTriggers(QAbstractItemView.NoEditTriggers) self.table_widget.resizeColumnsToContents() self.table_widget.setMaximumWidth(250) self.table_widget.setAlternatingRowColors(True) self.stopped = False self.comp_label.setEnabled(False) self.normal_radio.setEnabled(False) self.difference_radio.setEnabled(False) self.ssim_radio.setEnabled(False) self.butter_radio.setEnabled(False) self.gray_check.setEnabled(False) self.equalize_check.setEnabled(False) self.metric_button.setEnabled(False) self.table_widget.setEnabled(False) load_button.clicked.connect(self.load) self.normal_radio.clicked.connect(self.change) self.difference_radio.clicked.connect(self.change) self.butter_radio.clicked.connect(self.change) self.gray_check.stateChanged.connect(self.change) self.equalize_check.stateChanged.connect(self.change) self.ssim_radio.clicked.connect(self.change) self.evidence_viewer.viewChanged.connect( self.reference_viewer.changeView) self.reference_viewer.viewChanged.connect( self.evidence_viewer.changeView) self.metric_button.clicked.connect(self.metrics) top_layout = QHBoxLayout() top_layout.addWidget(load_button) top_layout.addStretch() top_layout.addWidget(self.comp_label) top_layout.addWidget(self.normal_radio) top_layout.addWidget(self.difference_radio) top_layout.addWidget(self.ssim_radio) top_layout.addWidget(self.butter_radio) top_layout.addWidget(self.gray_check) top_layout.addWidget(self.equalize_check) metric_layout = QVBoxLayout() index_label = QLabel(self.tr('Image Quality Assessment')) index_label.setAlignment(Qt.AlignCenter) modify_font(index_label, bold=True) metric_layout.addWidget(index_label) metric_layout.addWidget(self.table_widget) metric_layout.addWidget(self.metric_button) center_layout = QHBoxLayout() center_layout.addWidget(self.evidence_viewer) center_layout.addWidget(self.reference_viewer) center_layout.addLayout(metric_layout) main_layout = QVBoxLayout() main_layout.addLayout(top_layout) main_layout.addLayout(center_layout) self.setLayout(main_layout)
def __init__(self, image, parent=None): super(FrequencyWidget, self).__init__(parent) self.split_spin = QSpinBox() self.split_spin.setRange(0, 100) self.split_spin.setValue(15) self.split_spin.setSuffix(self.tr(' %')) self.smooth_spin = QSpinBox() self.smooth_spin.setRange(0, 100) self.smooth_spin.setValue(25) self.smooth_spin.setSuffix(self.tr(' %')) self.smooth_spin.setSpecialValueText(self.tr('Off')) self.thr_spin = QSpinBox() self.thr_spin.setRange(0, 100) self.thr_spin.setValue(0) self.thr_spin.setSuffix(self.tr(' %')) self.thr_spin.setSpecialValueText(self.tr('Off')) self.zero_label = QLabel() modify_font(self.zero_label, italic=True) self.filter_spin = QSpinBox() self.filter_spin.setRange(0, 15) self.filter_spin.setValue(0) self.filter_spin.setSuffix(self.tr(' px')) self.filter_spin.setSpecialValueText(self.tr('Off')) self.split_spin.valueChanged.connect(self.process) self.smooth_spin.valueChanged.connect(self.process) self.thr_spin.valueChanged.connect(self.process) self.filter_spin.valueChanged.connect(self.process) self.image = image gray = cv.cvtColor(self.image, cv.COLOR_BGR2GRAY) rows, cols = gray.shape height = cv.getOptimalDFTSize(rows) width = cv.getOptimalDFTSize(cols) padded = cv.copyMakeBorder(gray, 0, height - rows, 0, width - cols, cv.BORDER_CONSTANT) self.dft = np.fft.fftshift(cv.dft(padded.astype(np.float32), flags=cv.DFT_COMPLEX_OUTPUT)) self.magnitude, self.phase = cv.cartToPolar(self.dft[:, :, 0], self.dft[:, :, 1]) self.magnitude = cv.normalize(cv.log(self.magnitude), None, 0, 255, cv.NORM_MINMAX) self.phase = cv.normalize(self.phase, None, 0, 255, cv.NORM_MINMAX) self.low_viewer = ImageViewer(self.image, self.image, self.tr('Low frequency'), export=True) self.high_viewer = ImageViewer(self.image, self.image, self.tr('High frequency'), export=True) self.mag_viewer = ImageViewer(self.image, None, self.tr('DFT Magnitude'), export=True) self.phase_viewer = ImageViewer(self.image, None, self.tr('DFT Phase'), export=True) self.process() self.low_viewer.viewChanged.connect(self.high_viewer.changeView) self.high_viewer.viewChanged.connect(self.low_viewer.changeView) self.mag_viewer.viewChanged.connect(self.phase_viewer.changeView) self.phase_viewer.viewChanged.connect(self.mag_viewer.changeView) top_layout = QHBoxLayout() top_layout.addWidget(QLabel(self.tr('Separation:'))) top_layout.addWidget(self.split_spin) top_layout.addWidget(QLabel(self.tr('Smooth:'))) top_layout.addWidget(self.smooth_spin) top_layout.addWidget(QLabel(self.tr('Threshold:'))) top_layout.addWidget(self.thr_spin) top_layout.addWidget(QLabel(self.tr('Filter:'))) top_layout.addWidget(self.filter_spin) top_layout.addWidget(self.zero_label) top_layout.addStretch() center_layout = QGridLayout() center_layout.addWidget(self.low_viewer, 0, 0) center_layout.addWidget(self.high_viewer, 0, 1) center_layout.addWidget(self.mag_viewer, 1, 0) center_layout.addWidget(self.phase_viewer, 1, 1) main_layout = QVBoxLayout() main_layout.addLayout(top_layout) main_layout.addLayout(center_layout) self.setLayout(main_layout)
def __init__(self, parent=None, post_stats: bool = True): # instantiation super().__init__(parent, post_stats) self.ui.p1_layout = QVBoxLayout(self.ui.page_1) self.ui.p1_layout.setContentsMargins(0, 0, 0, 0) self.ui.p1_description = QLabel( 'This app calculates the mean flame height in accordance with ' '"PD 7974-1:2019 Application of fire safety engineering principles to the design of buildings. Part 1: ' 'Initiation and development of fire within the enclosure of origin (Sub-system 1)".' ) self.ui.p1_description.setFixedWidth(350) self.ui.p1_description.setWordWrap(True) self.ui.p1_layout.addWidget(self.ui.p1_description) self.ui.p1_figure = QLabel() self.ui.p1_figure.setPixmap(join(fsetoolsGUI.__root_dir__, 'gui', 'images', f'{self.app_id}-1.png')) self.ui.p1_layout.addWidget(self.ui.p1_figure) self.ui.p2_layout = QGridLayout(self.ui.page_2) self.ui.p2_layout.setVerticalSpacing(5), self.ui.p2_layout.setHorizontalSpacing(5) self.ui.p2_layout.addWidget(QLabel('<b>Inputs</b>'), 0, 0, 1, 3) self.add_lineedit_set_to_grid(self.ui.p2_layout, 1, 'p2_in_Q_dot_or_Q_dot_l', 'Total HRR', 'kW') self.add_lineedit_set_to_grid(self.ui.p2_layout, 2, 'p2_in_L_A_or_D', 'Fire diameter', 'm') self.add_lineedit_set_to_grid(self.ui.p2_layout, 3, 'p2_in_L_B', 'Fire shorter dimension', 'm') self.add_lineedit_set_to_grid(self.ui.p2_layout, 4, 'p2_in_rho_0', 'Air density', 'kg/m<sup>3</sup>') self.add_lineedit_set_to_grid(self.ui.p2_layout, 5, 'p2_in_c_p_0', 'Air heat capacity', 'kJ/kg/K') self.add_lineedit_set_to_grid(self.ui.p2_layout, 6, 'p2_in_T_0', 'Air temperature', 'K') self.add_lineedit_set_to_grid(self.ui.p2_layout, 7, 'p2_in_g', 'Gravity', 'm/s<sup>2</sup>') self.ui.p2_in_fire_shape = QComboBox() self.ui.p2_in_fire_shape.addItems(['Circular fire', 'Rectangular fire', 'Line fire']) self.ui.p2_layout.addWidget(self.ui.p2_in_fire_shape, 8, 0, 1, 3) self.ui.p2_in_fuel_type = QComboBox() self.ui.p2_in_fuel_type.addItems(['Natural gas (Zukoski)', 'Wood cribs', 'Gas, liquids and solids (Heskestad)']) self.ui.p2_layout.addWidget(self.ui.p2_in_fuel_type, 9, 0, 1, 3) self.ui.p2_layout.addWidget(QLabel('<b>Outputs</b>'), 10, 0, 1, 3) self.add_lineedit_set_to_grid(self.ui.p2_layout, 11, 'p2_out_Q_dot_star', 'Dimensionless HRR', '') self.ui.p2_out_Q_dot_star.setReadOnly(True) self.add_lineedit_set_to_grid(self.ui.p2_layout, 12, 'p2_out_Z_f', 'Flame height', 'm') self.ui.p2_out_Z_f.setReadOnly(True) # ============== # instantiate ui # ============== self.ui.p2_in_Q_dot_or_Q_dot_l.setToolTip( 'Total fire heat release rate (per unit length for line fire shape)') self.ui.p2_in_L_A_or_D.setToolTip('Fire longer dimension (diameter for circular fire shape)') self.ui.p2_in_L_B.setToolTip('Fire shorter dimension (only for rectangular fire shape)') self.ui.p2_out_Q_dot_star.setToolTip('Solved dimensionless heat release rate, double click to select') self.ui.p2_out_Z_f.setToolTip('Solved mean flame height, double click to select') # construct pixmaps that are used in this app self.dict_images_pixmap = dict(image_context=image_context, image_figure=image_figure, ) for k, v in self.dict_images_pixmap.items(): ba = QByteArray.fromBase64(v) self.dict_images_pixmap[k] = QtGui.QPixmap() self.dict_images_pixmap[k].loadFromData(ba) # set default values # todo self.change_fire_shape() # signal and slots self.ui.p2_in_fire_shape.currentIndexChanged.connect(self.change_fire_shape)
def __init__(self): QWidget.__init__(self) self.setWindowTitle("Backend Discord-GUI") self.changeStyle('fusion') palette = QPalette() palette.setColor(QPalette.Window, QColor(53, 53, 53)) palette.setColor(QPalette.WindowText, Qt.white) palette.setColor(QPalette.Text, Qt.white) palette.setColor(QPalette.Button, QColor(60, 60, 60)) palette.setColor(QPalette.ButtonText, Qt.white) palette.setColor(QPalette.Base, QColor(40, 40, 40)) palette.setColor(QPalette.ToolTipBase, QColor(60, 60, 60)) palette.setColor(QPalette.ToolTipText, Qt.white) palette.setColor(QPalette.PlaceholderText, Qt.white) palette.setColor(QPalette.BrightText, Qt.white) palette.setColor(QPalette.Highlight, QColor(106, 13, 173)) palette.setColor(QPalette.HighlightedText, Qt.white) topButtonLayout = QGroupBox("Configurations") topStatsLayout = QGroupBox("Statistics") layoutLeft = QHBoxLayout() botConfigButton = QPushButton("Bot Config") botConfigButton.clicked.connect(lambda: CommentPopup()) serverSettingsButton = QPushButton("Server Settings") settingsButton = QPushButton("Settings") layoutLeft.addWidget(botConfigButton) layoutLeft.addWidget(serverSettingsButton) layoutLeft.addWidget(settingsButton) layoutRight = QVBoxLayout() botReadyLabel = QLabel("Bot_Ready: False") botStatusLabel = QLabel("Bot_Status: Off") # botDatabaseLabel = QLabel("Bot_Database: None") # botStandbyLabel = QLabel("Bot_Standby: False") layoutRight.addWidget(botReadyLabel) layoutRight.addWidget(botStatusLabel) # layoutRight.addWidget(botDatabaseLabel) # layoutRight.addWidget(botStandbyLabel) topButtonLayout.setLayout(layoutLeft) topStatsLayout.setLayout(layoutRight) self.createLeftSide() self.createRightSide() self.createProgressBar() topLayout = QGridLayout() topLayout.addWidget(topButtonLayout, 0, 0) topLayout.addWidget(topStatsLayout, 0, 1) topLayout.setColumnStretch(0, 1) mainLayout = QGridLayout() mainLayout.addLayout(topLayout, 0, 0, 1, 2) mainLayout.addWidget(self.leftSideGB, 1, 0) mainLayout.addWidget(self.topRightGroupBox, 1, 1) mainLayout.addWidget(self.progressBar, 3, 0, 1, 2) mainLayout.setRowStretch(1, 2) mainLayout.setColumnStretch(0, 1) mainLayout.setColumnStretch(1, 2) self.setLayout(mainLayout) QApplication.setPalette(palette)
def __init__(self, Settings: QMainWindow): # Set window parameters Settings.setWindowTitle("ASL Tools - Settings") Settings.setWindowFlag(Qt.Window) icon_size = QSize(48, 48) # Main frame frame = QWidget() frame.setObjectName("mainwindow") self.v_layout = QVBoxLayout(frame) # Select tool window location self.label_location = QLabel() self.v_layout.addWidget(self.label_location) self.group_corner = QButtonGroup() self.grid_layout = QGridLayout() # Top left corner self.btn_corner_tl = QPushButton() self.btn_corner_tl.setObjectName("top-left") self.btn_corner_tl.setIcon(QIcon(":/images/corner-tl.svg")) self.btn_corner_tl.setIconSize(QSize(32, 32)) self.btn_corner_tl.setCheckable(True) self.group_corner.addButton(self.btn_corner_tl) self.grid_layout.addWidget(self.btn_corner_tl, 0, 1) # Top right corner self.btn_corner_tr = QPushButton() self.btn_corner_tr.setObjectName("top-right") self.btn_corner_tr.setIcon(QIcon(":/images/corner-tr.svg")) self.btn_corner_tr.setIconSize(QSize(32, 32)) self.btn_corner_tr.setCheckable(True) self.group_corner.addButton(self.btn_corner_tr) self.grid_layout.addWidget(self.btn_corner_tr, 0, 2) # bottom left corner self.btn_corner_bl = QPushButton() self.btn_corner_bl.setObjectName("bottom-left") self.btn_corner_bl.setIcon(QIcon(":/images/corner-bl.svg")) self.btn_corner_bl.setIconSize(QSize(32, 32)) self.btn_corner_bl.setCheckable(True) self.group_corner.addButton(self.btn_corner_bl) self.grid_layout.addWidget(self.btn_corner_bl, 1, 1) # Bottom right corner self.btn_corner_br = QPushButton() self.btn_corner_br.setObjectName("bottom-right") self.btn_corner_br.setIcon(QIcon(":/images/corner-br.svg")) self.btn_corner_br.setIconSize(QSize(32, 32)) self.btn_corner_br.setCheckable(True) self.group_corner.addButton(self.btn_corner_br) self.grid_layout.addWidget(self.btn_corner_br, 1, 2) # Spacers spacer = QSpacerItem(20, 20) self.grid_layout.addItem(spacer, 0, 0) spacer = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.grid_layout.addItem(spacer, 0, 3) self.v_layout.addLayout(self.grid_layout) # Window fit the layout Settings.setCentralWidget(frame) # Set size and position w, h = self.v_layout.sizeHint().toTuple() w_s, h_s = QApplication.primaryScreen().size().toTuple() x = round(w_s / 2 - w / 2) y = round(h_s / 2 - h / 2) Settings.setCentralWidget(frame) Settings.resize(w, h) Settings.move(x, y) self.retranslateUi(Settings) QtCore.QMetaObject.connectSlotsByName(Settings)
def createGridLayout(self): # Top grid with sceneview and diffraction pattern self.tophorizontalGroupBox = QGroupBox() toplayout = QGridLayout() # Add the SceneView widget self.view = interact.SceneView(self.scene) self.view.c.update_camera.connect(self.update_camera) toplayout.addWidget(self.view, 0, 0) # Add the diffraction widget dynamic_canvas = FigureCanvas(Figure(figsize=(15, 15))) toplayout.addWidget(dynamic_canvas, 0, 1) self.diffract_ax = dynamic_canvas.figure.add_subplot(111) self.diffract_ax.axis("off") self.diffract_ax.set_axis_off() self.plot_diffract(self.view.scene.camera) self.tophorizontalGroupBox.setLayout(toplayout) # Bottom grid with camera, buttons, zoom, sigma self.bothorizontalGroupBox = QGroupBox() botlayout = QGridLayout() # Camera printout self.label = QLabel() self.label.setText(self.camera_text(self.view.scene.camera)) # widget, row, col, rowspan, colspan botlayout.addWidget(self.label, 0, 0, 2, 1) # Buttons self.button100 = QPushButton("100") self.button100.setMaximumSize(QSize(100, 40)) botlayout.addWidget(self.button100, 0, 1, 2, 1) self.button110 = QPushButton("110") self.button110.setMaximumSize(QSize(100, 40)) botlayout.addWidget(self.button110, 0, 2, 2, 1) self.button111 = QPushButton("111") self.button111.setMaximumSize(QSize(100, 40)) botlayout.addWidget(self.button111, 0, 3, 2, 1) # Connect buttons to moving the camera # thanks to this wonderful answer https://stackoverflow.com/a/57167056/11969403 self.button100.clicked.connect(lambda: self.move_camera((1, 0, 0))) self.button110.clicked.connect(lambda: self.move_camera((1, 1, 0))) self.button111.clicked.connect(lambda: self.move_camera((1, 1, 1))) # Add space between buttons and slider botlayout.setColumnMinimumWidth(4, 350) # Zoom slider zlabel = QLabel("Zoom") zlabel.setAlignment(Qt.AlignCenter) botlayout.addWidget(zlabel, 0, 5) self.zooms = [i for i in range(1, self.d.N) if self.d.N % i == 0] self.zoomslider = QSlider(Qt.Horizontal) self.zoomslider.setMinimum(0) self.zoomslider.setMaximum(len(self.zooms) - 1) self.zoomslider.setValue(self.zooms.index(self.d.zoom)) self.zoomslider.valueChanged.connect(self.change_zoom) self.zoomslider.setMaximumSize(QSize(600, 30)) botlayout.addWidget(self.zoomslider, 1, 5) botlayout.setColumnMinimumWidth(6, 50) self.bothorizontalGroupBox.setLayout(botlayout)
def __init__(self, conn): ''' Parameters: conn : connection Connection to the database. ''' super().__init__() self.setWindowTitle('Aggiungi Prenotazione') self.setWindowFlag(QtCore.Qt.WindowContextHelpButtonHint, False) self.conn = conn self.cursor = conn.cursor() self.books = dict() self.books_qt = dict() self.gen_layout = QVBoxLayout() self.form_layout = QFormLayout() self.form_layout.setRowWrapPolicy(QFormLayout.WrapLongRows) # Widgets self.client_field = QLineEdit() self.form_layout.addRow('Numero Cliente: ', self.client_field) self.dip_field = QLineEdit() self.form_layout.addRow('Dipendente (CF): ', self.dip_field) self.date_picker = QDateEdit(QDate.currentDate()) self.date_picker.setDisplayFormat("MM/dd/yyyy") self.date_picker.setCalendarPopup(True) self.form_layout.addRow('Data (mm/gg/aaaa): ', self.date_picker) self.importo_field = QDoubleSpinBox() self.importo_field.setMaximum(999999999.99) self.form_layout.addRow('Importo: ', self.importo_field) self.ins_layout = QHBoxLayout() self.libro_field = QLineEdit() self.quantita_field = QSpinBox() self.quantita_field.setMinimum(1) self.libro_button = QPushButton('Aggiungi') self.libro_button.clicked.connect(self.aggiungi_libro) self.ins_layout.addWidget(QLabel('Libro (ISBN): ')) self.ins_layout.addWidget(self.libro_field) self.ins_layout.addWidget(QLabel('Quantità: ')) self.ins_layout.addWidget(self.quantita_field) self.ins_layout.addWidget(self.libro_button) self.labels = ['ISBN', 'Quantità', ''] self.table = QTableWidget(0, 3) self.table.setHorizontalHeaderLabels(self.labels) self.table.horizontalHeader().setSectionResizeMode( 0, QHeaderView.Stretch) self.table.horizontalHeader().setSectionResizeMode( 1, QHeaderView.Stretch) self.table.horizontalHeader().setSectionResizeMode( 2, QHeaderView.ResizeToContents) self.info_label = QLabel( 'Le prenotazioni non riducono i libri disponibili.') self.confirm_button = QPushButton('Conferma') self.confirm_button.clicked.connect(self.post_prenotazione) self.gen_layout.addLayout(self.form_layout) self.gen_layout.addLayout(self.ins_layout) self.gen_layout.addWidget(self.table) self.gen_layout.addWidget(self.info_label) self.gen_layout.addWidget(self.confirm_button) self.setLayout(self.gen_layout)
def __init__(self, filename, parent=None): super(QualityWidget, self).__init__(parent) MRK = b'\xFF' SOI = b'\xD8' DQT = b'\xDB' # DHT = b'\xC4' MSK = b'\x0F' PAD = b'\x00' MAX_TABLES = 2 LEN_OFFSET = 2 LUMA_IDX = 0 CHROMA_IDX = 1 luma = np.zeros((DCT_SIZE, DCT_SIZE), dtype=int) chroma = np.zeros((DCT_SIZE, DCT_SIZE), dtype=int) temp_file = QTemporaryFile() if temp_file.open(): copyfile(filename, temp_file.fileName()) subprocess.run([ exiftool_exe(), '-all=', '-overwrite_original', temp_file.fileName() ], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) found = False with open(temp_file.fileName(), 'rb') as file: first = file.read(1) if first not in [MRK, SOI]: self.show_error(self.tr('File is not a JPEG image!')) return while True: if not self.find_next(file, [MRK, DQT, PAD]): break length = file.read(1)[0] - LEN_OFFSET if length <= 0 or length % (TABLE_SIZE + 1) != 0: continue while length > 0: mode = file.read(1) if not mode: break index = mode[0] & MSK[0] if index >= MAX_TABLES: break length -= 1 for k in range(TABLE_SIZE): b = file.read(1)[0] if not b: break length -= 1 i, j = ZIG_ZAG[k] if index == LUMA_IDX: luma[i, j] = b elif index == CHROMA_IDX: chroma[i, j] = b else: found = True if not found: self.show_error(self.tr('Unable to find JPEG tables!')) return levels = [(1 - (np.mean(t.ravel()[1:]) - 1) / 254) * 100 for t in [luma, chroma]] distance = np.zeros(101) for q in range(101): lu, ch = cv.split(get_tables(q)) lu_diff = np.mean(cv.absdiff(luma, lu)) ch_diff = np.mean(cv.absdiff(chroma, ch)) distance[q] = (lu_diff + 2 * ch_diff) / 3 closest = np.argmin(distance) deviation = distance[closest] if deviation == 0: quality = closest message = '(standard tables)' else: quality = int(np.round(closest - deviation)) message = '(deviation from standard = {:.4f})'.format(deviation) quality_label = QLabel( self.tr('Last saved JPEG quality: {}% {}'.format(quality, message))) modify_font(quality_label, bold=True) luma_label = QLabel( self.tr('Luminance Quantization Table (level = {:.2f}%)\n'.format( levels[0]))) luma_label.setAlignment(Qt.AlignCenter) modify_font(luma_label, underline=True) luma_table = self.create_table(luma) luma_table.setMaximumHeight(200) chroma_label = QLabel( self.tr( 'Chrominance Quantization Table (level = {:.2f}%)\n'.format( levels[1]))) chroma_label.setAlignment(Qt.AlignCenter) modify_font(chroma_label, underline=True) chroma_table = self.create_table(chroma) chroma_table.setMaximumHeight(200) main_layout = QGridLayout() main_layout.addWidget(luma_label, 0, 0) main_layout.addWidget(luma_table, 1, 0) main_layout.addWidget(chroma_label, 0, 1) main_layout.addWidget(chroma_table, 1, 1) main_layout.addWidget(quality_label, 2, 0, 1, 2) self.setLayout(main_layout) self.setFixedSize(880, 270)
def __init__(self): super().__init__() self.label = QLabel("Click in this window") self.status = self.statusBar() self.setFixedSize(QSize(200, 100)) self.setCentralWidget(self.label)
def _create_file_list_item_widget(self, rel_path, created_time, was_updated, icon_info): abs_path = op.join(self._config.sync_directory, rel_path) abs_path = ensure_unicode(abs_path) abs_path = FilePath(abs_path).longpath widget = QWidget(parent=self._ui.file_list) widget.created_time = created_time widget.was_updated = was_updated widget.mouseReleaseEvent = lambda _: \ qt_reveal_file_in_file_manager( widget.get_link_button.abs_path) main_layout = QHBoxLayout(widget) icon_label = QLabel(widget) widget.icon_label = icon_label main_layout.addWidget(icon_label) vertical_layout = QVBoxLayout() main_layout.addLayout(vertical_layout) file_name_label = QLabel(widget) widget.file_name_label = file_name_label vertical_layout.addWidget(file_name_label) horizontal_layout = QHBoxLayout() vertical_layout.addLayout(horizontal_layout) time_delta_label = QLabel(widget) widget.time_delta_label = time_delta_label horizontal_layout.addWidget(time_delta_label, alignment=Qt.AlignTop) get_link_button = QPushButton(widget) widget.get_link_button = get_link_button horizontal_layout.addWidget(get_link_button, alignment=Qt.AlignTop) self._set_icon_label(icon_info, icon_label) file_name_label.setFixedSize(304, 24) file_name_label.setFont(QFont('Noto Sans', 10 * self._dp)) file_name_label.setAlignment(Qt.AlignTop | Qt.AlignLeft) file_name_label.setText( elided(rel_path, file_name_label)) time_delta_label.setText(get_added_time_string( created_time, was_updated, False)) time_delta_label.setFont(QFont('Noto Sans', 8 * self._dp, italic=True)) time_delta_label.setMinimumSize(time_delta_label.width(), 24) time_delta_label.setAlignment(Qt.AlignTop | Qt.AlignLeft) time_delta_label.setStyleSheet('color: #A792A9;') get_link_button.setText(' {} '.format(tr('Get link'))) get_link_button.setFlat(True) get_link_button.setChecked(True) get_link_button.setMinimumSize(120, 24) get_link_button.setFont(QFont("Noto Sans", 8 * self._dp, italic=True)) get_link_button.setMouseTracking(True) self._setup_get_link_button(get_link_button, rel_path, abs_path) return widget
def initUI(self): self.setWindowTitle('Image Tesselator') layout_container = QHBoxLayout() menu_layout = QVBoxLayout() button = QPushButton('Choose Picture') button.clicked.connect(self.selectFile) menu_layout.addWidget(button) generation_layout = QGridLayout() generation_layout.addWidget(QLabel("Generation Types"), 0, 0) generation_type = QComboBox() generation_type.addItems(["Random", "Highest Entropy"]) generation_type.activated[str].connect(self.update_generation_type) policy = QSizePolicy() policy.setHorizontalPolicy(QSizePolicy.Expanding) generation_type.setSizePolicy(policy) generation_layout.addWidget(generation_type, 0, 1) menu_layout.addLayout(generation_layout) points_layout = QGridLayout() points_layout.addWidget(QLabel("Point Count"), 0, 0) self.slider_field.setAlignment(Qt.AlignCenter) self.slider_field.setValidator(QIntValidator()) self.slider_field.textChanged[str].connect(self.update_points_field) self.slider_field.setText("0") points_layout.addWidget(self.slider_field, 0, 1) slider = QSlider(Qt.Horizontal) slider.setSingleStep(10) slider.setMinimum(0) slider.setMaximum(1000) slider.valueChanged[int].connect(self.update_points_slider) points_layout.addWidget(slider, 1, 0, 1, 2) menu_layout.addLayout(points_layout) menu_layout.addWidget(QPushButton('Generate Tesselation')) picture_viewer = QGridLayout() pixmap = QPixmap(240, 240) pixmap.fill(QColor(53, 53, 53)) self.original_pic.setPixmap(pixmap) self.point_line_pic.setPixmap(pixmap) self.tesselated_pic.setPixmap(pixmap) for i, pic in enumerate( [self.original_pic, self.point_line_pic, self.tesselated_pic]): picture_viewer.addWidget(pic, 0, i) for i, label in enumerate( ["Original", "Chosen Points & Triangles", "Tesselated"]): pic_label = QLabel(label) pic_label.setAlignment(Qt.AlignCenter) picture_viewer.addWidget(pic_label, 1, i) layout_container.addLayout(menu_layout) layout_container.addLayout(picture_viewer) self.setLayout(layout_container) self.show()
def __init__(self, predefined_models_window, parent: "QWidget" = None): super().__init__(parent) # Model picker size (left) self._predefined_models_window = predefined_models_window self._predefined_models_group = QGroupBox("Predefined Models:") self._predefined_models_layout = QHBoxLayout() self._predefined_models_layout.setContentsMargins(0, 0, 0, 0) self._predefined_models_group.setLayout(self._predefined_models_layout) self._predefined_models_layout.addWidget( self._predefined_models_window) # Description Side (right) self._model_name = QLabel("") self._include_top = QCheckBox("Include") self._include_top.setChecked(True) self._shape_textbox = QLineEdit("(224, 224, 3)") self._shape_textbox.setEnabled(False) self._classes_intbox = QSpinBox() self._classes_intbox.setMinimum(2) self._classes_intbox.setMaximum(999999) self._classes_intbox.setValue(1000) self._weights_combobox = QComboBox() self._weights_combobox.addItem("Imagenet", "imagenet") self._weights_combobox.addItem("None", None) # Add widgets to layout self._description_group = QGroupBox("Description:") self._description_layout = QFormLayout() self._description_group.setLayout(self._description_layout) self._description_layout.addRow("Name:", self._model_name) self._description_layout.addRow("Include Top:", self._include_top) self._description_layout.addRow("Input Shape:", self._shape_textbox) self._description_layout.addRow("Classes:", self._classes_intbox) self._description_layout.addRow("Weights:", self._weights_combobox) self._main_layout = QHBoxLayout() self._main_layout.addWidget(self._predefined_models_group) self._main_layout.addWidget(self._description_group) self.setLayout(self._main_layout) sp_left = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sp_left.setHorizontalStretch(1) self._predefined_models_group.setSizePolicy(sp_left) sp_right = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sp_right.setHorizontalStretch(2.5) self._description_group.setSizePolicy(sp_right) self._include_top.stateChanged.connect( lambda: self._update_enabled_widgets()) self._weights_combobox.currentIndexChanged[int].connect( lambda: self._update_enabled_widgets()) self._predefined_models_window.selected_model_changed.connect( self._update_description_labels) self._update_enabled_widgets()
def __init__(self, targetImage=None, axeSize=500, layer=None, parent=None): super().__init__(layer=layer, targetImage=targetImage, parent=parent) ####################################### # Libraw correspondences: # rgb_xyz_matrix is libraw cam_xyz # camera_whitebalance is libraw cam_mul # daylight_whitebalance is libraw pre_mul # dng correspondences: # ASSHOTNEUTRAL tag value is (X,Y,Z) = 1 / rawpyObj.camera_whitebalance ########################################## rawpyObj = layer.parentImage.rawImage # constants and as shot values self.XYZ2CameraMatrix = rawpyObj.rgb_xyz_matrix[:3, :] self.XYZ2CameraInverseMatrix = np.linalg.inv(self.XYZ2CameraMatrix) # initial post processing multipliers (as shot) m1, m2, m3, m4 = rawpyObj.camera_whitebalance self.asShotMultipliers = (m1/m2, 1.0, m3/m2, m4/m2) # normalization is mandatory : for nef files white balance is around 256 self.asShotTemp, self.asShotTint = multipliers2TemperatureAndTint(*1 / np.array(self.asShotMultipliers[:3]), self.XYZ2CameraMatrix) self.rawMultipliers = self.asShotMultipliers # rawpyObj.camera_whitebalance # = 1/(dng ASSHOTNEUTRAL tag value) self.sampleMultipliers = False self.samples = [] ######################################## # XYZ-->Camera conversion matrix: # Last row is zero for RGB cameras (cf. rawpy and libraw docs). # type ndarray, shape (4,3) ######################################### # attributes initialized in setDefaults, declared here for the sake of correctness self.tempCorrection, self.tintCorrection, self.expCorrection, self.highCorrection,\ self.contCorrection, self.satCorrection, self.brCorrection = [None] * 7 # contrast spline vie (initialized by setContrastSpline) self.contrastForm = None # tone spline view (initialized by setToneSpline) self.toneForm = None # dock containers for contrast and tome forms self.dockC, self.dockT = None, None # options optionList0, optionNames0 = ['Auto Brightness', 'Preserve Highlights'], ['Auto Expose', 'Preserve Highlights'] optionList1, optionNames1 = ['Auto WB', 'Camera WB', 'User WB'], ['Auto', 'Camera (As Shot)', 'User'] optionList2, optionNames2 = ['cpLookTable', 'cpToneCurve', 'manualCurve'], ['Use Camera Profile Look Table', 'Show Tone Curves', 'Show Contrast Curve'] self.listWidget1 = optionsWidget(options=optionList0, optionNames=optionNames0, exclusive=False, changed=lambda: self.dataChanged.emit(1)) self.listWidget2 = optionsWidget(options=optionList1, optionNames=optionNames1, exclusive=True, changed=lambda: self.dataChanged.emit(1)) self.listWidget3 = optionsWidget(options=optionList2, optionNames=optionNames2, exclusive=False, changed=lambda: self.dataChanged.emit(2)) self.options = UDict((self.listWidget1.options, self.listWidget2.options, self.listWidget3.options)) # display the 'as shot' temperature item = self.listWidget2.item(1) item.setText(item.text() + ' : %d' % self.asShotTemp) # temperature slider self.sliderTemp = QbLUeSlider(Qt.Horizontal) self.sliderTemp.setStyleSheet(QbLUeSlider.bLueSliderDefaultColorStylesheet) self.sliderTemp.setRange(0, 100) self.sliderTemp.setSingleStep(1) self.tempLabel = QLabel() self.tempLabel.setText("Temp") self.tempValue = QLabel() font = self.tempValue.font() metrics = QFontMetrics(font) w = metrics.width("10000") h = metrics.height() self.tempValue.setMinimumSize(w, h) self.tempValue.setMaximumSize(w, h) self.tempValue.setText(str("{:.0f}".format(self.slider2Temp(self.sliderTemp.value())))) self.sliderTemp.valueChanged.connect(self.tempUpdate) # signal send new value as parameter self.sliderTemp.sliderReleased.connect(lambda: self.tempUpdate(self.sliderTemp.value())) # signal pass no parameter # tint slider self.sliderTint = QbLUeSlider(Qt.Horizontal) self.sliderTint.setStyleSheet(QbLUeSlider.bLueSliderDefaultIMGColorStylesheet) self.sliderTint.setRange(0, 150) self.sliderTint.setSingleStep(1) self.tintLabel = QLabel() self.tintLabel.setText("Tint") self.tintValue = QLabel() font = self.tempValue.font() metrics = QFontMetrics(font) w = metrics.width("100") h = metrics.height() self.tintValue.setMinimumSize(w, h) self.tintValue.setMaximumSize(w, h) self.tintValue.setText(str("{:.0f}".format(self.sliderTint2User(self.sliderTint.value())))) self.sliderTint.valueChanged.connect(self.tintUpdate) self.sliderTint.sliderReleased.connect(lambda: self.tintUpdate(self.sliderTint.value())) # signal pass no parameter) ###################### # From libraw and dcraw sources: # Exposure and brightness are curve transformations. # Exposure curve is y = alpha*x, with cubic root ending; it is applied before demosaicing. # Brightness is (similar to) y = x**alpha and part of gamma transformation from linear sRGB to RGB. # Exposure and brightness both dilate the histogram towards highlights. # Exposure dilatation is uniform (homothety), brightness dilataion is # maximum for the midtones and the highlghts are preserved. # As a consequence, normal workflow begins with the adjustment of exposure, # to fill the entire range of the histogram and to adjust the highlights. Next, # one adjusts the brightness to put the midtones at the level we want them to be. # Cf. https://www.cambridgeincolour.com/forums/thread653.htm ##################### # profile combo self.dngDict = self.setCameraProfilesCombo() # cameraProfilesCombo index changed event handler def cameraProfileUpdate(value): self.dngDict = self.cameraProfilesCombo.itemData(value) if self.options['cpToneCurve']: toneCurve = dngProfileToneCurve(self.dngDict.get('ProfileToneCurve', [])) self.toneForm.baseCurve = [QPointF(x * axeSize, -y * axeSize) for x, y in zip(toneCurve.dataX, toneCurve.dataY)] self.toneForm.update() # recompute as shot temp and tint using new profile self.asShotTemp, self.asShotTint = multipliers2TemperatureAndTint(*1 / np.array(self.asShotMultipliers[:3]), self.XYZ2CameraMatrix, self.dngDict) # display updated as shot temp item = self.listWidget2.item(1) item.setText(item.text().split(":")[0] + ': %d' % self.asShotTemp) # invalidate cache self.layer.bufCache_HSV_CV32 = None self.dataChanged.emit(2) # 2 = no postprocessing self.cameraProfilesCombo.currentIndexChanged.connect(cameraProfileUpdate) # denoising combo self.denoiseCombo = QComboBox() items = OrderedDict([('Off', 0), ('Medium', 1), ('Full', 2)]) for key in items: self.denoiseCombo.addItem(key, items[key]) # denoiseCombo index changed event handler def denoiseUpdate(value): self.denoiseValue = self.denoiseCombo.itemData(value) self.dataChanged.emit(1) self.denoiseCombo.currentIndexChanged.connect(denoiseUpdate) # overexposed area restoration self.overexpCombo = QComboBox() items = OrderedDict([('Clip', 0), ('Ignore', 1), ('Blend', 2), ('Reconstruct', 3)]) for key in items: self.overexpCombo.addItem(key, items[key]) # overexpCombo index changed event handler def overexpUpdate(value): self.overexpValue = self.overexpCombo.itemData(value) self.dataChanged.emit(1) self.overexpCombo.currentIndexChanged.connect(overexpUpdate) # exp slider self.sliderExp = QbLUeSlider(Qt.Horizontal) self.sliderExp.setStyleSheet(QbLUeSlider.bLueSliderDefaultBWStylesheet) self.sliderExp.setRange(0, 100) self.sliderExp.setSingleStep(1) self.expLabel = QLabel() self.expLabel.setText("Exp.") self.expValue = QLabel() font = self.expValue.font() metrics = QFontMetrics(font) w = metrics.width("+1.0") h = metrics.height() self.expValue.setMinimumSize(w, h) self.expValue.setMaximumSize(w, h) self.expValue.setText(str("{:.1f}".format(self.slider2Exp(self.sliderExp.value())))) # exp done event handler def expUpdate(value): self.expValue.setText(str("{:+.1f}".format(self.sliderExp2User(self.sliderExp.value())))) # move not yet terminated or value not modified if self.sliderExp.isSliderDown() or self.slider2Exp(value) == self.expCorrection: return try: self.sliderExp.valueChanged.disconnect() self.sliderExp.sliderReleased.disconnect() except RuntimeError: pass # rawpy: expCorrection range is -2.0...3.0, boiling down to exp_shift range 2**(-2)=0.25...2**3=8.0 self.expCorrection = self.slider2Exp(self.sliderExp.value()) self.dataChanged.emit(1) self.sliderExp.valueChanged.connect(expUpdate) # send new value as parameter self.sliderExp.sliderReleased.connect(lambda: expUpdate(self.sliderExp.value())) # signal pass no parameter self.sliderExp.valueChanged.connect(expUpdate) # send new value as parameter self.sliderExp.sliderReleased.connect(lambda: expUpdate(self.sliderExp.value())) # signal pass no parameter # brightness slider brSlider = QbLUeSlider(Qt.Horizontal) brSlider.setRange(1, 101) self.sliderExp.setSingleStep(1) brSlider.setStyleSheet(QbLUeSlider.bLueSliderDefaultBWStylesheet) self.sliderBrightness = brSlider brLabel = QLabel() brLabel.setText("Bright.") self.brValue = QLabel() font = self.expValue.font() metrics = QFontMetrics(font) w = metrics.width("+99") h = metrics.height() self.brValue.setMinimumSize(w, h) self.brValue.setMaximumSize(w, h) self.brValue.setText(str("{:+d}".format(int(self.brSlider2User(self.sliderBrightness.value()))))) # brightness done event handler def brUpdate(value): self.brValue.setText(str("{:+d}".format(int(self.brSlider2User(self.sliderBrightness.value()))))) # move not yet terminated or value not modified if self.sliderBrightness.isSliderDown() or self.slider2Br(value) == self.brCorrection: return try: self.sliderBrightness.valueChanged.disconnect() self.sliderBrightness.sliderReleased.disconnect() except RuntimeError: pass self.brCorrection = self.slider2Br(self.sliderBrightness.value()) self.dataChanged.emit(1) self.sliderBrightness.sliderReleased.connect(lambda: brUpdate(self.sliderBrightness.value())) self.sliderBrightness.valueChanged.connect(brUpdate) # send new value as parameter self.sliderBrightness.valueChanged.connect(brUpdate) # send new value as parameter self.sliderBrightness.sliderReleased.connect(lambda: brUpdate(self.sliderBrightness.value())) # contrast slider self.sliderCont = QbLUeSlider(Qt.Horizontal) self.sliderCont.setStyleSheet(QbLUeSlider.bLueSliderDefaultBWStylesheet) self.sliderCont.setRange(0, 20) self.sliderCont.setSingleStep(1) self.contLabel = QLabel() self.contLabel.setText("Cont.") self.contValue = QLabel() font = self.contValue.font() metrics = QFontMetrics(font) w = metrics.width("100") h = metrics.height() self.contValue.setMinimumSize(w, h) self.contValue.setMaximumSize(w, h) self.contValue.setText(str("{:.0f}".format(self.slider2Cont(self.sliderCont.value())))) # cont done event handler def contUpdate(value): self.contValue.setText(str("{:.0f}".format(self.slider2Cont(self.sliderCont.value())))) # move not yet terminated or value not modified if self.sliderCont.isSliderDown() or self.slider2Cont(value) == self.tempCorrection: return try: self.sliderCont.valueChanged.disconnect() self.sliderCont.sliderReleased.disconnect() except RuntimeError: pass self.contCorrection = self.slider2Cont(self.sliderCont.value()) self.contValue.setText(str("{:+d}".format(self.contCorrection))) # force to recalculate the spline self.layer.autoSpline = True self.dataChanged.emit(3) # no postprocessing and no camera profile stuff self.sliderCont.valueChanged.connect(contUpdate) # send new value as parameter self.sliderCont.sliderReleased.connect(lambda: contUpdate(self.sliderCont.value())) # signal has no parameter self.sliderCont.valueChanged.connect(contUpdate) # send new value as parameter self.sliderCont.sliderReleased.connect(lambda: contUpdate(self.sliderCont.value())) # signal has no parameter # saturation slider self.sliderSat = QbLUeSlider(Qt.Horizontal) self.sliderSat.setStyleSheet(QbLUeSlider.bLueSliderDefaultColorStylesheet) self.sliderSat.setRange(0, 100) self.sliderSat.setSingleStep(1) satLabel = QLabel() satLabel.setText("Sat.") self.satValue = QLabel() font = self.satValue.font() metrics = QFontMetrics(font) w = metrics.width("+10") h = metrics.height() self.satValue.setMinimumSize(w, h) self.satValue.setMaximumSize(w, h) self.satValue.setText(str("{:+d}".format(self.slider2Sat(self.sliderSat.value())))) """sat done event handler""" def satUpdate(value): self.satValue.setText(str("{:+d}".format(self.slider2Sat(self.sliderSat.value())))) # move not yet terminated or value not modified if self.sliderSat.isSliderDown() or self.slider2Sat(value) == self.satCorrection: return try: self.sliderSat.valueChanged.disconnect() self.sliderSat.sliderReleased.disconnect() except RuntimeError: pass self.satCorrection = self.slider2Sat(self.sliderSat.value()) self.dataChanged.emit(3) # no post processing and no camera profile stuff self.sliderSat.valueChanged.connect(satUpdate) # send new value as parameter self.sliderSat.sliderReleased.connect(lambda: satUpdate(self.sliderSat.value())) # signal has no parameter self.sliderSat.valueChanged.connect(satUpdate) # send new value as parameter self.sliderSat.sliderReleased.connect(lambda: satUpdate(self.sliderSat.value())) # signal has no parameter self.setStyleSheet("QListWidget, QLabel {font : 7pt;}") # layout l = QVBoxLayout() l.addWidget(self.listWidget3) hl01 = QHBoxLayout() hl01.addWidget(QLabel('Camera Profile')) hl01.addWidget(self.cameraProfilesCombo) l.addLayout(hl01) hl0 = QHBoxLayout() hl0.addWidget(QLabel('Denoising')) hl0.addWidget(self.denoiseCombo) l.addLayout(hl0) hl00 = QHBoxLayout() hl00.addWidget(QLabel('Overexp. Restoration')) hl00.addWidget(self.overexpCombo) l.addLayout(hl00) hl1 = QHBoxLayout() hl1.addWidget(self.expLabel) hl1.addWidget(self.expValue) hl1.addWidget(self.sliderExp) l.addLayout(hl1) hl8 = QHBoxLayout() hl8.addWidget(brLabel) hl8.addWidget(self.brValue) hl8.addWidget(self.sliderBrightness) l.addLayout(hl8) l.addWidget(self.listWidget1) self.listWidget2.setStyleSheet("QListWidget {border: 0px;} QListWidget::item {border: 0px; padding-left: 20px;}") vl1 = QVBoxLayout() vl1.addWidget(QLabel('White Balance')) vl1.addWidget(self.listWidget2) gb1 = QGroupBox() gb1.setStyleSheet("QGroupBox {border: 1px solid gray; border-radius: 4px}") hl2 = QHBoxLayout() hl2.addWidget(self.tempLabel) hl2.addWidget(self.tempValue) hl2.addWidget(self.sliderTemp) hl3 = QHBoxLayout() hl3.addWidget(self.tintLabel) hl3.addWidget(self.tintValue) hl3.addWidget(self.sliderTint) vl1.addLayout(hl2) vl1.addLayout(hl3) gb1.setLayout(vl1) l.addWidget(gb1) hl4 = QHBoxLayout() hl4.addWidget(self.contLabel) hl4.addWidget(self.contValue) hl4.addWidget(self.sliderCont) hl7 = QHBoxLayout() hl7.addWidget(satLabel) hl7.addWidget(self.satValue) hl7.addWidget(self.sliderSat) # separator sep = QFrame() sep.setFrameShape(QFrame.HLine) sep.setFrameShadow(QFrame.Sunken) l.addWidget(sep) l.addLayout(hl4) l.addLayout(hl7) l.addStretch(1) self.setLayout(l) self.adjustSize() self.setDefaults() self.setWhatsThis( """<b>Development of raw files</b><br> <b>Default settings</b> are a good starting point.<br> A <b>Tone Curve</b> is applied to the raw image prior to postprocessing.<br> The cuvre can be edited by checking the option <b>Show Tone Curve</b>; this option works best with manual exposure.<br> <b>Contrast</b> correction is based on an automatic algorithm well suited to multi-mode histograms.<br> <b>Brightness, Contrast</b> and <b>Saturation</b> levels</b> are adjustable with the correponding sliders.<br> The <b>Contrast Curve</b> can be edited manually by checking the option <b>Show Contrast Curve</b>.<br> Uncheck <b>Auto Expose</b> to adjust the exposure manually.<br> The <b>OverExp. Rest.</b> slider controls the mode of restoration of overexposed areas. Valid values are 0 to 3 (0=clip;1=unclip;2=blend;3=rebuild); (with Auto Exposed checked the mode is clip).<br> """ ) # end of setWhatsThis
def __init__(self): super().__init__() self.setWindowTitle("JpegToPdf") self.setMinimumHeight(250) self.setMinimumWidth(250) self.qv_box = QVBoxLayout() self.qh_box = QHBoxLayout() self.w = QWidget() self.w.setLayout(self.qv_box) self.setCentralWidget(self.w) self.show() #Buttons ...... self.button_1 = QPushButton("Image1") self.button_1.clicked.connect( lambda: self.button_clicked(self.button_1)) self.button_2 = QPushButton("Image2") self.button_2.clicked.connect( lambda: self.button_clicked(self.button_2)) self.button_3 = QPushButton("Image3") self.button_3.clicked.connect( lambda: self.button_clicked(self.button_3)) self.button_start = QPushButton("Start") self.button_open_dir = QPushButton("Open Folder") self.button_open_dir.setEnabled(False) self.button_open_dir.clicked.connect( lambda: self.open(self.button_open_dir)) self.button_open_file = QPushButton("Open File") self.button_open_file.setEnabled(False) self.button_open_file.clicked.connect( lambda: self.open(self.button_open_file)) #Labels....... self.button_1_label = QLabel() self.button_2_label = QLabel() self.button_3_label = QLabel() self.button_start_label = QLabel() self.button_start.clicked.connect(self.start) self.qv_box.addWidget(self.button_1) self.qv_box.addWidget(self.button_1_label) self.qv_box.addWidget(self.button_2) self.qv_box.addWidget(self.button_2_label) self.qv_box.addWidget(self.button_3) self.qv_box.addWidget(self.button_3_label) self.qv_box.addWidget(self.button_start) self.qv_box.addWidget(self.button_start_label) self.qh_box.addWidget(self.button_open_dir) self.qh_box.addWidget(self.button_open_file) self.qv_box.addLayout(self.qh_box)
import sys from PySide2.QtWidgets import QApplication, QMainWindow, QLineEdit, QLabel, QPushButton aplicacao = QApplication(sys.argv) janela = QMainWindow() janela.setGeometry( 100, 50, 300, 200 ) janela.setWindowTitle("Primeira Janela") texto_entrada = QLineEdit(janela) texto_entrada.move(50, 10) texto_entrada.resize(200, 30) label = QLabel("Texto Obtido:", janela) label.move(50, 90) label.resize(200,30) resultado = QLabel("", janela) resultado.move(50, 120) resultado.resize(200,30) def onButtonClick(): # atribui o valor da caixa de texto para o label resultado resultado.setText(texto_entrada.text()) # texto_entrada.text() obtém o valor que está na caixa de texto button = QPushButton("Obter texto", janela) button.move(50, 50) button.resize(205,30) # determina a função que sera executada ao clicar no botão button.clicked.connect(onButtonClick)
def setup_ui(self, main_dialog): """Initializes the UI""" main_dialog.setObjectName("main_dialog") main_dialog.resize(395, 284) main_dialog.setStyleSheet(STYLE) self.target_path_line_edit = QLineEdit(main_dialog) self.target_path_line_edit.setGeometry(QRect(10, 10, 291, 20)) self.target_path_line_edit.setObjectName("target_path_line_edit") self.browse_path_btn = QPushButton(main_dialog) self.browse_path_btn.setGeometry(QRect(310, 9, 75, 23)) self.browse_path_btn.setFocusPolicy(Qt.NoFocus) self.browse_path_btn.setObjectName("browse_path_btn") self.prefix_chk = QCheckBox(main_dialog) self.prefix_chk.setGeometry(QRect(10, 43, 70, 17)) self.prefix_chk.setFocusPolicy(Qt.NoFocus) self.prefix_chk.setObjectName("prefix_chk") self.prefix_line_edit = QLineEdit(main_dialog) self.prefix_line_edit.setEnabled(False) self.prefix_line_edit.setGeometry(QRect(90, 42, 294, 20)) self.prefix_line_edit.setObjectName("prefix_line_edit") self.suff_chk = QCheckBox(main_dialog) self.suff_chk.setGeometry(QRect(10, 71, 70, 17)) self.suff_chk.setFocusPolicy(Qt.NoFocus) self.suff_chk.setObjectName("suff_chk") self.suff_line_edit = QLineEdit(main_dialog) self.suff_line_edit.setEnabled(False) self.suff_line_edit.setGeometry(QRect(90, 70, 294, 20)) self.suff_line_edit.setObjectName("suff_line_edit") self.rename_chk = QCheckBox(main_dialog) self.rename_chk.setGeometry(QRect(10, 101, 70, 17)) self.rename_chk.setFocusPolicy(Qt.NoFocus) self.rename_chk.setChecked(True) self.rename_chk.setObjectName("rename_chk") self.rename_old_line_edit = QLineEdit(main_dialog) self.rename_old_line_edit.setEnabled(True) self.rename_old_line_edit.setGeometry(QRect(90, 100, 140, 20)) self.rename_old_line_edit.setObjectName("rename_old_line_edit") self.rename_new_line_edit = QLineEdit(main_dialog) self.rename_new_line_edit.setEnabled(True) self.rename_new_line_edit.setGeometry(QRect(242, 100, 141, 20)) self.rename_new_line_edit.setObjectName("rename_new_line_edit") self.ext_chk = QCheckBox(main_dialog) self.ext_chk.setGeometry(QRect(10, 131, 110, 17)) self.ext_chk.setFocusPolicy(Qt.NoFocus) self.ext_chk.setObjectName("ext_chk") self.ext_line_edit = QLineEdit(main_dialog) self.ext_line_edit.setEnabled(False) self.ext_line_edit.setGeometry(QRect(133, 130, 251, 20)) self.ext_line_edit.setObjectName("ext_line_edit") self.include_subdir_chk = QCheckBox(main_dialog) self.include_subdir_chk.setGeometry(QRect(134, 170, 128, 17)) self.include_subdir_chk.setFocusPolicy(Qt.NoFocus) self.include_subdir_chk.setObjectName("include_subdir_chk") self.prev_file_name_title_label = QLabel(main_dialog) self.prev_file_name_title_label.setGeometry(QRect(20, 201, 90, 13)) self.prev_file_name_title_label.setObjectName( "prev_file_name_title_label") self.prev_file_name_label = QLabel(main_dialog) self.prev_file_name_label.setGeometry(QRect(124, 201, 260, 13)) self.prev_file_name_label.setObjectName("prev_file_name_label") self.rename_files_btn = QPushButton(main_dialog) self.rename_files_btn.setGeometry(QRect(156, 230, 91, 41)) self.rename_files_btn.setFocusPolicy(Qt.NoFocus) self.rename_files_btn.setObjectName("rename_files_btn") self.view_log_btn = QPushButton(main_dialog) self.view_log_btn.setGeometry(QRect(310, 255, 75, 23)) self.view_log_btn.setFocusPolicy(Qt.NoFocus) self.view_log_btn.setObjectName("view_log_btn") self.retranslate_ui(main_dialog) QMetaObject.connectSlotsByName(main_dialog)
def setup_ui(self): layout = QGridLayout() def v_changed(*a): size = self.value = Size(w_box.value(), h_box.value()) valid = (size not in self.blacklist ) and size.height > 0 and size.width > 0 ok_btn.setEnabled(valid) if not valid: msg = 'size is invalid' if size in self.blacklist: msg = 'size is present' else: msg = size.ratio() v_label.setText(f'{size.width}x{size.height}\n{msg}') w_box = QSpinBox() w_box.setMinimum(1) w_box.setMaximum(1_000_000) w_box.valueChanged.connect(v_changed) h_box = QSpinBox() h_box.setMinimum(1) h_box.setMaximum(1_000_000) h_box.valueChanged.connect(v_changed) x_label = QLabel('x') x_label.setAlignment(Qt.AlignCenter) layout.addWidget(w_box, 0, 0) layout.addWidget(x_label, 0, 1) layout.addWidget(h_box, 0, 2) v_label = QLabel() v_label.setAlignment(Qt.AlignCenter) layout.addWidget(v_label, 1, 0) preset_btn = QPushButton('Get From Screen') try: import screeninfo as si except ImportError: si = None preset_btn.setEnabled(False) else: @preset_btn.clicked.connect def _(*a): candidates = set() for m in si.get_monitors(): candidates.add((m.width, m.height)) if len(candidates) != 1: QMessageBox.warning( self, 'multiple monitors not yet supported') # todo else: w, h = next(iter(candidates)) w_box.setValue(w) h_box.setValue(h) layout.addWidget(preset_btn, 1, 2) cancel_btn = QPushButton('Cancel') cancel_btn.clicked.connect(self.reject) layout.addWidget(cancel_btn, 2, 0) ok_btn = QPushButton('Ok') ok_btn.clicked.connect(self.accept) layout.addWidget(ok_btn, 2, 2) self.setLayout(layout) v_changed()
def __init__(self, image, parent=None): super(ToolWidget, self).__init__(parent) self.value_radio = QRadioButton(self.tr("Value")) self.value_radio.setChecked(True) self.last_radio = self.value_radio self.red_radio = QRadioButton(self.tr("Red")) self.green_radio = QRadioButton(self.tr("Green")) self.blue_radio = QRadioButton(self.tr("Blue")) self.rgb_radio = QRadioButton(self.tr("RGB")) self.smooth_check = QCheckBox(self.tr("Smooth line")) self.smooth_check.setToolTip(self.tr("Interpolated values plot")) self.log_check = QCheckBox(self.tr("Log scale")) self.log_check.setToolTip(self.tr("Y-axes logarithmic scale")) self.grid_check = QCheckBox(self.tr("Show grid")) self.grid_check.setToolTip(self.tr("Display XY main grid lines")) self.marker_check = QCheckBox(self.tr("Show markers")) self.marker_check.setToolTip( self.tr("Show plot markers for min(--), avg(-), max(-.)")) self.start_slider = ParamSlider([0, 255], 8, 0, bold=True) self.end_slider = ParamSlider([0, 255], 8, 255, bold=True) channels = cv.split(cv.cvtColor(image, cv.COLOR_BGR2RGB)) channels.append(cv.cvtColor(image, cv.COLOR_BGR2GRAY)) self.hist = [compute_hist(c) for c in channels] rows, cols, chans = image.shape pixels = rows * cols self.unique_colors = np.unique(np.reshape(image, (pixels, chans)), axis=0).shape[0] self.unique_ratio = np.round(self.unique_colors / pixels * 100, 2) self.value_radio.clicked.connect(self.redraw) self.red_radio.clicked.connect(self.redraw) self.green_radio.clicked.connect(self.redraw) self.blue_radio.clicked.connect(self.redraw) self.rgb_radio.clicked.connect(self.redraw) self.smooth_check.stateChanged.connect(self.redraw) self.log_check.stateChanged.connect(self.redraw) self.grid_check.stateChanged.connect(self.redraw) self.marker_check.stateChanged.connect(self.redraw) self.start_slider.valueChanged.connect(self.redraw) self.end_slider.valueChanged.connect(self.redraw) self.table_widget = QTableWidget(13, 2) self.table_widget.setHorizontalHeaderLabels( [self.tr("Property"), self.tr("Value")]) self.table_widget.setItem(0, 0, QTableWidgetItem(self.tr("Least frequent"))) self.table_widget.item(0, 0).setToolTip( self.tr("Value that appears less")) self.table_widget.setItem(1, 0, QTableWidgetItem(self.tr("Most frequent"))) self.table_widget.item(1, 0).setToolTip( self.tr("Value that appears more")) self.table_widget.setItem(2, 0, QTableWidgetItem(self.tr("Average level"))) self.table_widget.item(2, 0).setToolTip(self.tr("Histogram mean value")) self.table_widget.setItem(3, 0, QTableWidgetItem(self.tr("Median level"))) self.table_widget.item(3, 0).setToolTip(self.tr("Histogram median value")) self.table_widget.setItem(4, 0, QTableWidgetItem(self.tr("Deviation"))) self.table_widget.item(4, 0).setToolTip( self.tr("Histogram standard deviation")) self.table_widget.setItem(5, 0, QTableWidgetItem(self.tr("Pixel count"))) self.table_widget.item(5, 0).setToolTip( self.tr("Total values in current range")) self.table_widget.setItem(6, 0, QTableWidgetItem(self.tr("Percentile"))) self.table_widget.item(6, 0).setToolTip( self.tr("Percentage of total pixels")) self.table_widget.setItem(7, 0, QTableWidgetItem(self.tr("Nonzero range"))) self.table_widget.item(7, 0).setToolTip( self.tr("Minimal range without empty bins")) self.table_widget.setItem(8, 0, QTableWidgetItem(self.tr("Empty bins"))) self.table_widget.item(8, 0).setToolTip( self.tr("Number of missing values")) self.table_widget.setItem(9, 0, QTableWidgetItem(self.tr("Unique colors"))) self.table_widget.item(9, 0).setToolTip(self.tr("Unique RGB color count")) self.table_widget.setItem(10, 0, QTableWidgetItem(self.tr("Unique ratio"))) self.table_widget.item(10, 0).setToolTip( self.tr("Unique colors vs total pixels")) self.table_widget.setItem(11, 0, QTableWidgetItem(self.tr("Smoothness"))) self.table_widget.item(11, 0).setToolTip( self.tr("Estimated correlation among bin values")) self.table_widget.setItem(12, 0, QTableWidgetItem(self.tr("Fullness"))) self.table_widget.item(12, 0).setToolTip( self.tr("Area covered vs total size")) for i in range(self.table_widget.rowCount()): modify_font(self.table_widget.item(i, 0), bold=True) self.table_widget.setSelectionMode(QAbstractItemView.SingleSelection) self.table_widget.setEditTriggers(QAbstractItemView.NoEditTriggers) self.table_widget.setAlternatingRowColors(True) self.table_widget.setMinimumWidth(200) self.table_widget.resizeColumnsToContents() figure = Figure() plot_canvas = FigureCanvas(figure) self.axes = plot_canvas.figure.subplots() self.redraw() figure.set_tight_layout(True) range_layout = QGridLayout() range_layout.addWidget(QLabel(self.tr("Start:")), 0, 0) range_layout.addWidget(self.start_slider, 0, 1) range_layout.addWidget(QLabel(self.tr("End:")), 1, 0) range_layout.addWidget(self.end_slider, 1, 1) right_frame = QFrame() right_layout = QVBoxLayout() right_layout.addWidget(self.table_widget) right_layout.addLayout(range_layout) right_frame.setLayout(right_layout) center_split = QSplitter() center_split.addWidget(plot_canvas) center_split.addWidget(right_frame) bottom_layout = QHBoxLayout() bottom_layout.addWidget(QLabel(self.tr("Channel:"))) bottom_layout.addWidget(self.value_radio) bottom_layout.addWidget(self.red_radio) bottom_layout.addWidget(self.green_radio) bottom_layout.addWidget(self.blue_radio) bottom_layout.addWidget(self.rgb_radio) bottom_layout.addStretch() bottom_layout.addWidget(self.smooth_check) bottom_layout.addWidget(self.log_check) bottom_layout.addWidget(self.grid_check) bottom_layout.addWidget(self.marker_check) main_layout = QVBoxLayout() main_layout.addWidget(center_split) main_layout.addLayout(bottom_layout) self.setLayout(main_layout)
def __init__(self): QMainWindow.__init__(self, None) self.setObjectName(_fromUtf8("MainWindow")) self.resize(651, 280) self.setMinimumSize(QtCore.QSize(0, 250)) self.centralwidget = QWidget(self) self.centralwidget.setObjectNasqlBtnme(_fromUtf8("centralwidget")) self.verticalLayout = QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.gridLayout = QGridLayout() self.gridLayout.setObjectName(_fromUtf8("gridLayout")) spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.gridLayout.addItem(spacerItem1, 0, 0, 1, 1) self.excelBtn = QPushButton(self.centralwidget) self.excelBtn.setMinimumSize(QtCore.QSize(200, 0)) self.excelBtn.setObjectName(_fromUtf8("excelBtn")) self.gridLayout.addWidget(self.excelBtn, 0, 1, 1, 1) self.sqlBtn = QPushButton(self.centralwidget) self.sqlBtn.setMinimumSize(QtCore.QSize(200, 0)) self.sqlBtn.setObjectName(_fromUtf8("sqlBtn")) self.gridLayout.addWidget(self.sqlBtn, 0, 3, 1, 1) self.runBtn = QPushButton(self.centralwidget) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.runBtn.sizePolicy().hasHeightForWidth()) self.runBtn.setSizePolicy(sizePolicy) self.runBtn.setEnabled(False) self.runBtn.setMouseTracking(False) self.runBtn.setAutoFillBackground(False) self.runBtn.setStyleSheet(_fromUtf8("border: none;")) self.runBtn.setText(_fromUtf8("")) icon = QIcon() icon.addPixmap(QPixmap(_fromUtf8("icons/run.png")), QIcon.Normal, QIcon.Off) self.runBtn.setIcon(icon) self.runBtn.setIconSize(QtCore.QSize(64, 64)) self.runBtn.setObjectName(_fromUtf8("runBtn")) self.gridLayout.addWidget(self.runBtn, 0, 2, 2, 1) spacerItem2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.gridLayout.addItem(spacerItem2, 0, 4, 1, 1) self.sqlLabel = QLabel(self.centralwidget) self.sqlLabel.setText(_fromUtf8("")) self.sqlLabel.setObjectName(_fromUtf8("sqlLabel")) self.gridLayout.addWidget(self.sqlLabel, 1, 3, 1, 2) self.excelLabel = QLabel(self.centralwidget) self.excelLabel.setText(_fromUtf8("")) self.excelLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.excelLabel.setObjectName(_fromUtf8("excelLabel")) self.gridLayout.addWidget(self.excelLabel, 1, 0, 1, 2) self.verticalLayout.addLayout(self.gridLayout) spacerItem3 = QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem3) self.setCentralWidget(self.centralwidget) self.statusbar = QStatusBar(self) self.statusbar.setObjectName(_fromUtf8("statusbar")) self.setStatusBar(self.statusbar) self.retranslateUi() QtCore.QMetaObject.connectSlotsByName(self) self.excelFileName = None self.sqlFileName = "/home/eamon/Desktop/test.sqlite" self.sqlLabel.setText(self.sqlFileName) self.excelBtn.clicked.connect(self, QtCore.SLOT("onExcelBtnClick()")) self.sqlBtn.clicked.connect(self, QtCore.SLOT("onSqlBtnClick()")) self.runBtn.clicked.connect(self, QtCore.SLOT("onRunBtnClick()"))
def __init__(self, context, parent=None): super(Snippets, self).__init__(parent) # Create widgets self.setWindowModality(Qt.ApplicationModal) self.title = QLabel(self.tr("Snippet Editor")) self.saveButton = QPushButton(self.tr("&Save")) self.saveButton.setShortcut(QKeySequence(self.tr("Ctrl+S"))) self.runButton = QPushButton(self.tr("&Run")) self.runButton.setShortcut(QKeySequence(self.tr("Ctrl+R"))) self.closeButton = QPushButton(self.tr("Close")) self.clearHotkeyButton = QPushButton(self.tr("Clear Hotkey")) self.setWindowTitle(self.title.text()) #self.newFolderButton = QPushButton("New Folder") self.browseButton = QPushButton("Browse Snippets") self.browseButton.setIcon(QIcon.fromTheme("edit-undo")) self.deleteSnippetButton = QPushButton("Delete") self.newSnippetButton = QPushButton("New Snippet") self.edit = QCodeEditor(HIGHLIGHT_CURRENT_LINE=False, SyntaxHighlighter=PythonHighlighter) self.edit.setPlaceholderText("python code") self.resetting = False self.columns = 3 self.context = context self.keySequenceEdit = QKeySequenceEdit(self) self.currentHotkey = QKeySequence() self.currentHotkeyLabel = QLabel("") self.currentFileLabel = QLabel() self.currentFile = "" self.snippetDescription = QLineEdit() self.snippetDescription.setPlaceholderText("optional description") #Set Editbox Size font = getMonospaceFont(self) self.edit.setFont(font) font = QFontMetrics(font) self.edit.setTabStopWidth(4 * font.width(' ')); #TODO, replace with settings API #Files self.files = QFileSystemModel() self.files.setRootPath(snippetPath) self.files.setNameFilters(["*.py"]) #Tree self.tree = QTreeView() self.tree.setModel(self.files) self.tree.setSortingEnabled(True) self.tree.hideColumn(2) self.tree.sortByColumn(0, Qt.AscendingOrder) self.tree.setRootIndex(self.files.index(snippetPath)) for x in range(self.columns): #self.tree.resizeColumnToContents(x) self.tree.header().setSectionResizeMode(x, QHeaderView.ResizeToContents) treeLayout = QVBoxLayout() treeLayout.addWidget(self.tree) treeButtons = QHBoxLayout() #treeButtons.addWidget(self.newFolderButton) treeButtons.addWidget(self.browseButton) treeButtons.addWidget(self.newSnippetButton) treeButtons.addWidget(self.deleteSnippetButton) treeLayout.addLayout(treeButtons) treeWidget = QWidget() treeWidget.setLayout(treeLayout) # Create layout and add widgets buttons = QHBoxLayout() buttons.addWidget(self.clearHotkeyButton) buttons.addWidget(self.keySequenceEdit) buttons.addWidget(self.currentHotkeyLabel) buttons.addWidget(self.closeButton) buttons.addWidget(self.runButton) buttons.addWidget(self.saveButton) description = QHBoxLayout() description.addWidget(QLabel(self.tr("Description: "))) description.addWidget(self.snippetDescription) vlayoutWidget = QWidget() vlayout = QVBoxLayout() vlayout.addLayout(description) vlayout.addWidget(self.edit) vlayout.addLayout(buttons) vlayoutWidget.setLayout(vlayout) hsplitter = QSplitter() hsplitter.addWidget(treeWidget) hsplitter.addWidget(vlayoutWidget) hlayout = QHBoxLayout() hlayout.addWidget(hsplitter) self.showNormal() #Fixes bug that maximized windows are "stuck" #Because you can't trust QT to do the right thing here if (sys.platform == "darwin"): self.settings = QSettings("Vector35", "Snippet Editor") else: self.settings = QSettings("Vector 35", "Snippet Editor") if self.settings.contains("ui/snippeteditor/geometry"): self.restoreGeometry(self.settings.value("ui/snippeteditor/geometry")) else: self.edit.setMinimumWidth(80 * font.averageCharWidth()) self.edit.setMinimumHeight(30 * font.lineSpacing()) # Set dialog layout self.setLayout(hlayout) # Add signals self.saveButton.clicked.connect(self.save) self.closeButton.clicked.connect(self.close) self.runButton.clicked.connect(self.run) self.clearHotkeyButton.clicked.connect(self.clearHotkey) self.tree.selectionModel().selectionChanged.connect(self.selectFile) self.newSnippetButton.clicked.connect(self.newFileDialog) self.deleteSnippetButton.clicked.connect(self.deleteSnippet) #self.newFolderButton.clicked.connect(self.newFolder) self.browseButton.clicked.connect(self.browseSnippets) if self.settings.contains("ui/snippeteditor/selected"): selectedName = self.settings.value("ui/snippeteditor/selected") self.tree.selectionModel().select(self.files.index(selectedName), QItemSelectionModel.ClearAndSelect | QItemSelectionModel.Rows) if self.tree.selectionModel().hasSelection(): self.selectFile(self.tree.selectionModel().selection(), None) self.edit.setFocus() cursor = self.edit.textCursor() cursor.setPosition(self.edit.document().characterCount()-1) self.edit.setTextCursor(cursor) else: self.readOnly(True) else: self.readOnly(True)
def init_ui(self): self.data_table = QTableWidget(100, 100) self.data_table.setEditTriggers(QAbstractItemView.NoEditTriggers) self.data_table.setSelectionBehavior(QAbstractItemView.SelectRows) self.data_table.setAlternatingRowColors(True) self.data_table.setContextMenuPolicy(Qt.CustomContextMenu) self.main_layout = QGridLayout(self) self.main_layout.addWidget(self.data_table, 0, 0, 1, 3) self.previous_button = QPushButton( qta.icon("mdi.skip-previous-circle"), self.tr("Previous")) self.previous_button.setToolTip( self.tr("Click to back to the previous page.")) self.previous_button.clicked.connect(self.on_previous_button_clicked) self.current_page_combo_box = QComboBox() self.current_page_combo_box.addItem(self.tr("Page {0}").format(1)) self.current_page_combo_box.currentIndexChanged.connect( self.update_page) self.next_button = QPushButton(qta.icon("mdi.skip-next-circle"), self.tr("Next")) self.next_button.setToolTip(self.tr("Click to jump to the next page.")) self.next_button.clicked.connect(self.on_next_button_clicked) self.main_layout.addWidget(self.previous_button, 1, 0) self.main_layout.addWidget(self.current_page_combo_box, 1, 1) self.main_layout.addWidget(self.next_button, 1, 2) self.distance_label = QLabel(self.tr("Distance")) self.distance_label.setToolTip( self. tr("It's the function to calculate the difference (on the contrary, similarity) between two samples." )) self.distance_combo_box = QComboBox() self.distance_combo_box.addItems(built_in_distances) self.distance_combo_box.setCurrentText("log10MSE") self.distance_combo_box.currentTextChanged.connect( lambda: self.update_page(self.page_index)) self.main_layout.addWidget(self.distance_label, 2, 0) self.main_layout.addWidget(self.distance_combo_box, 2, 1, 1, 2) self.menu = QMenu(self.data_table) self.mark_action = self.menu.addAction( qta.icon("mdi.marker-check"), self.tr("Mark Selection(s) as Reference")) self.mark_action.triggered.connect(self.mark_selections) self.unmark_action = self.menu.addAction( qta.icon("mdi.do-not-disturb"), self.tr("Unmark Selection(s)")) self.unmark_action.triggered.connect(self.unmark_selections) self.remove_action = self.menu.addAction( qta.icon("fa.remove"), self.tr("Remove Selection(s)")) self.remove_action.triggered.connect(self.remove_selections) self.remove_all_action = self.menu.addAction(qta.icon("fa.remove"), self.tr("Remove All")) self.remove_all_action.triggered.connect(self.remove_all_results) self.plot_loss_chart_action = self.menu.addAction( qta.icon("mdi.chart-timeline-variant"), self.tr("Plot Loss Chart")) self.plot_loss_chart_action.triggered.connect(self.show_distance) self.plot_distribution_chart_action = self.menu.addAction( qta.icon("fa5s.chart-area"), self.tr("Plot Distribution Chart")) self.plot_distribution_chart_action.triggered.connect( self.show_distribution) self.plot_distribution_animation_action = self.menu.addAction( qta.icon("fa5s.chart-area"), self.tr("Plot Distribution Chart (Animation)")) self.plot_distribution_animation_action.triggered.connect( self.show_history_distribution) self.load_dump_action = self.menu.addAction( qta.icon("fa.database"), self.tr("Load Binary Dump")) self.load_dump_action.triggered.connect( lambda: self.load_dump(mark_ref=True)) self.save_dump_action = self.menu.addAction( qta.icon("fa.save"), self.tr("Save Binary Dump")) self.save_dump_action.triggered.connect(self.save_dump) self.data_table.customContextMenuRequested.connect(self.show_menu)
def __init__(self): QMainWindow.__init__(self, None) self.setObjectName(_fromUtf8("MainWindow")) self.resize(536, 392) self.centralwidget = QWidget(self) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.tabWidget = QTabWidget(self.centralwidget) self.tabWidget.setGeometry(QtCore.QRect(10, 10, 521, 361)) self.tabWidget.setTabsClosable(False) self.tabWidget.setObjectName(_fromUtf8("tabWidget")) self.Insert = QWidget() self.Insert.setObjectName(_fromUtf8("Insert")) self.layoutWidget_2 = QWidget(self.Insert) self.layoutWidget_2.setGeometry(QtCore.QRect(10, 100, 504, 76)) self.layoutWidget_2.setObjectName(_fromUtf8("layoutWidget_2")) self.gridLayout = QGridLayout(self.layoutWidget_2) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.gridLayout.addItem(spacerItem, 0, 0, 1, 1) self.excelBtn = QPushButton(self.layoutWidget_2) self.excelBtn.setMinimumSize(QtCore.QSize(200, 0)) self.excelBtn.setObjectName(_fromUtf8("excelBtn")) self.gridLayout.addWidget(self.excelBtn, 0, 1, 1, 1) self.excelLabel = QLabel(self.layoutWidget_2) self.excelLabel.setText(_fromUtf8("")) self.excelLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.excelLabel.setObjectName(_fromUtf8("excelLabel")) self.gridLayout.addWidget(self.excelLabel, 1, 0, 1, 2) self.sqlBtn = QPushButton(self.layoutWidget_2) self.sqlBtn.setMinimumSize(QtCore.QSize(200, 0)) self.sqlBtn.setObjectName(_fromUtf8("sqlBtn")) self.gridLayout.addWidget(self.sqlBtn, 0, 3, 1, 1) self.runBtn = QPushButton(self.layoutWidget_2) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.runBtn.sizePolicy().hasHeightForWidth()) self.runBtn.setSizePolicy(sizePolicy) self.runBtn.setMouseTracking(False) self.runBtn.setAutoFillBackground(False) self.runBtn.setStyleSheet(_fromUtf8("background: transparent;")) self.runBtn.setText(_fromUtf8("")) icon = QIcon() icon.addPixmap(QPixmap(_fromUtf8("icons/run.png")), QIcon.Normal, QIcon.Off) self.runBtn.setIcon(icon) self.runBtn.setIconSize(QtCore.QSize(64, 64)) self.runBtn.setObjectName(_fromUtf8("runBtn")) self.gridLayout.addWidget(self.runBtn, 0, 2, 2, 1) spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.gridLayout.addItem(spacerItem1, 0, 4, 1, 1) self.tabWidget.addTab(self.Insert, _fromUtf8("")) self.Search = QWidget() self.Search.setObjectName(_fromUtf8("Search")) self.layoutWidget = QWidget(self.Search) self.layoutWidget.setGeometry(QtCore.QRect(0, 10, 541, 29)) self.layoutWidget.setObjectName(_fromUtf8("layoutWidget")) self.horizontalLayout = QHBoxLayout(self.layoutWidget) self.horizontalLayout.setSizeConstraint(QLayout.SetDefaultConstraint) self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) spacerItem2 = QSpacerItem(40, 20, QSizePolicy.MinimumExpanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem2) self.searchTE = QLineEdit(self.layoutWidget) self.searchTE.setObjectName(_fromUtf8("searchTE")) self.horizontalLayout.addWidget(self.searchTE) self.pushButton_2 = QPushButton(self.layoutWidget) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.pushButton_2.sizePolicy().hasHeightForWidth()) self.pushButton_2.setSizePolicy(sizePolicy) self.pushButton_2.setMaximumSize(QtCore.QSize(32, 16777215)) self.pushButton_2.setStyleSheet(_fromUtf8("color: blue")) self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) self.horizontalLayout.addWidget(self.pushButton_2) self.searchBtn = QPushButton(self.layoutWidget) sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.searchBtn.sizePolicy().hasHeightForWidth()) self.searchBtn.setSizePolicy(sizePolicy) self.searchBtn.setStyleSheet(_fromUtf8("border: none")) self.searchBtn.setText(_fromUtf8("")) icon1 = QIcon() icon1.addPixmap( QPixmap( _fromUtf8( "../../.designer/gitlab/ExcelToSql/icons/searchBtn.png")), QIcon.Normal, QIcon.Off) self.searchBtn.setIcon(icon1) self.searchBtn.setIconSize(QtCore.QSize(48, 24)) self.searchBtn.setObjectName(_fromUtf8("searchBtn")) self.horizontalLayout.addWidget(self.searchBtn) self.tableWidget = QTableWidget(self.Search) self.tableWidget.setGeometry(QtCore.QRect(0, 50, 541, 271)) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.tableWidget.sizePolicy().hasHeightForWidth()) self.tableWidget.setSizePolicy(sizePolicy) self.tableWidget.setObjectName(_fromUtf8("tableWidget")) self.tableWidget.setColumnCount(3) self.tableWidget.setRowCount(0) item = QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(0, item) item = QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(1, item) item = QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(2, item) self.tabWidget.addTab(self.Search, _fromUtf8("")) self.tab = QWidget() self.tab.setObjectName(_fromUtf8("tab")) self.tabWidget.addTab(self.tab, _fromUtf8("")) self.setCentralWidget(self.centralwidget) self.statusBar = QStatusBar(self) self.statusBar.setObjectName(_fromUtf8("statusbar")) self.setStatusBar(self.statusBar) self.retranslateUi(self) self.tabWidget.setCurrentIndex(1) QtCore.QMetaObject.connectSlotsByName(self) self.excelFileName = None self.sqlFileName = "/home/eamon/Desktop/test.sqlite" self.sqlLabel.setText(self.sqlFileName) self.excelBtn.clicked.connect(self, QtCore.SLOT("onExcelBtnClick()")) self.sqlBtn.clicked.connect(self, QtCore.SLOT("onSqlBtnClick()")) self.runBtn.clicked.connect(self, QtCore.SLOT("onRunBtnClick()"))
def __init__(self): QWidget.__init__(self) self.q = None self.pool = None self.top = QHBoxLayout() self.top.setMargin(10) self.radioButtonMov = QRadioButton("电影") self.radioButtonCinema = QRadioButton("连续剧/综艺/动漫") self.top.addWidget(self.radioButtonMov) self.top.addWidget(self.radioButtonCinema) self.middle = QVBoxLayout() self.middle.setMargin(10) self.url_label = QLabel() self.url = QLineEdit() self.url_label.setBuddy(self.url) self.middle.addWidget(self.url_label) self.middle.addWidget(self.url) self.browse_folder_label = QLabel("下载到:") self.browseFolder = QPushButton("选择目录") self.browse_folder_label.setBuddy(self.browseFolder) self.middle.addWidget(self.browse_folder_label) self.middle.addWidget(self.browseFolder) self.browse_folder_value = "" self.dest_file_label = QLabel() # "输入电影/电视剧名 (用来命名下载的文件/目录): " title set by choose_movie_widgets() later self.folder_or_filename = QLineEdit() self.dest_file_label.setBuddy(self.folder_or_filename) self.middle.addWidget(self.dest_file_label) self.middle.addWidget(self.folder_or_filename) self.bk_cinemae_spin_from = 1 self.bk_cinemae_spin_to = 1 self.fromEpSpinBox = QSpinBox() self.fromEpSpinBox.setMinimum(1) self.fromEpSpinBox.setMaximum(2147483647) self.fromEpLabel = QLabel("&从第几集开始下载:") self.fromEpLabel.setBuddy(self.fromEpSpinBox) self.toEpSpinBox = QSpinBox() self.toEpSpinBox.setMinimum(1) self.toEpSpinBox.setMaximum(2147483647) self.toEpLabel = QLabel("&到第几集停止下载:") self.toEpLabel.setBuddy(self.toEpSpinBox) self.cinema_ly = QHBoxLayout() #self.cinema_ly.setMargin(10) self.cinema_ly.addWidget(self.fromEpLabel) self.cinema_ly.addWidget(self.fromEpSpinBox) self.cinema_ly.addWidget(self.toEpLabel) self.cinema_ly.addWidget(self.toEpSpinBox) self.middle.addLayout(self.cinema_ly) self.proxy_label = QLabel("(如有)代理:") self.proxy = QLineEdit() self.proxy_label.setBuddy(self.proxy) self.middle.addWidget(self.proxy_label) self.middle.addWidget(self.proxy) self.add = QPushButton("开始下载") self.add.setEnabled(False) self.middle.addWidget(self.add) self.stop_me = QPushButton("停止下载") self.stop_me.setEnabled(False) self.middle.addWidget(self.stop_me) self.log_area = QPlainTextEdit() self.log_area.setReadOnly(True) self.log_area.setMaximumBlockCount(1000) self.middle.addWidget(self.log_area) #self.table_view.setSizePolicy(size) #self.layout.addWidget(self.table) self.layout = QVBoxLayout() self.layout.addLayout(self.top) self.layout.addLayout(self.middle) self.setLayout(self.layout) self.radioButtonMov.toggled.connect(self.choose_movie_widgets) self.radioButtonCinema.toggled.connect(self.choose_cinema_widgets) self.url.textChanged[str].connect(self.check_disable_download) self.browseFolder.clicked.connect(self.add_folder) self.folder_or_filename.textChanged[str].connect( self.check_disable_download) self.add.clicked.connect(self.start_download) self.stop_me.clicked.connect(self.stop_download) self.radioButtonMov.setChecked( True) #set default only after .connect above # TESTING PURPOSE ''' self.radioButtonMov.setChecked(False) self.url.setText('https://www.duboku.net/voddetail-969.html') self.browse_folder_value = 'C:/Users/Administrator/Documents/duboku' self.folder_or_filename.setText('初恋') ''' #set current process (not queue that one) log handler: logger = logging.getLogger(__name__) handler2 = LoggerWriter() logger.addHandler(handler2) logger.setLevel(logging.INFO) #DEBUG handler2.emitter.sigLog.connect(self.log_area.appendPlainText) sys.stdout = handler2 #LoggerWriter()
def __init__(self): super(Window, self).__init__() self.renderArea = RenderArea() self.shapeComboBox = QComboBox() self.shapeComboBox.addItem("Polygon", RenderArea.Polygon) self.shapeComboBox.addItem("Rectangle", RenderArea.Rect) self.shapeComboBox.addItem("Rounded Rectangle", RenderArea.RoundedRect) self.shapeComboBox.addItem("Ellipse", RenderArea.Ellipse) self.shapeComboBox.addItem("Pie", RenderArea.Pie) self.shapeComboBox.addItem("Chord", RenderArea.Chord) self.shapeComboBox.addItem("Path", RenderArea.Path) self.shapeComboBox.addItem("Line", RenderArea.Line) self.shapeComboBox.addItem("Polyline", RenderArea.Polyline) self.shapeComboBox.addItem("Arc", RenderArea.Arc) self.shapeComboBox.addItem("Points", RenderArea.Points) self.shapeComboBox.addItem("Text", RenderArea.Text) self.shapeComboBox.addItem("Pixmap", RenderArea.Pixmap) shapeLabel = QLabel("&Shape:") shapeLabel.setBuddy(self.shapeComboBox) self.penWidthSpinBox = QSpinBox() self.penWidthSpinBox.setRange(0, 20) self.penWidthSpinBox.setSpecialValueText("0 (cosmetic pen)") penWidthLabel = QLabel("Pen &Width:") penWidthLabel.setBuddy(self.penWidthSpinBox) self.penStyleComboBox = QComboBox() self.penStyleComboBox.addItem("Solid", Qt.SolidLine) self.penStyleComboBox.addItem("Dash", Qt.DashLine) self.penStyleComboBox.addItem("Dot", Qt.DotLine) self.penStyleComboBox.addItem("Dash Dot", Qt.DashDotLine) self.penStyleComboBox.addItem("Dash Dot Dot", Qt.DashDotDotLine) self.penStyleComboBox.addItem("None", Qt.NoPen) penStyleLabel = QLabel("&Pen Style:") penStyleLabel.setBuddy(self.penStyleComboBox) self.penCapComboBox = QComboBox() self.penCapComboBox.addItem("Flat", Qt.FlatCap) self.penCapComboBox.addItem("Square", Qt.SquareCap) self.penCapComboBox.addItem("Round", Qt.RoundCap) penCapLabel = QLabel("Pen &Cap:") penCapLabel.setBuddy(self.penCapComboBox) self.penJoinComboBox = QComboBox() self.penJoinComboBox.addItem("Miter", Qt.MiterJoin) self.penJoinComboBox.addItem("Bevel", Qt.BevelJoin) self.penJoinComboBox.addItem("Round", Qt.RoundJoin) penJoinLabel = QLabel("Pen &Join:") penJoinLabel.setBuddy(self.penJoinComboBox) self.brushStyleComboBox = QComboBox() self.brushStyleComboBox.addItem("Linear Gradient", Qt.LinearGradientPattern) self.brushStyleComboBox.addItem("Radial Gradient", Qt.RadialGradientPattern) self.brushStyleComboBox.addItem("Conical Gradient", Qt.ConicalGradientPattern) self.brushStyleComboBox.addItem("Texture", Qt.TexturePattern) self.brushStyleComboBox.addItem("Solid", Qt.SolidPattern) self.brushStyleComboBox.addItem("Horizontal", Qt.HorPattern) self.brushStyleComboBox.addItem("Vertical", Qt.VerPattern) self.brushStyleComboBox.addItem("Cross", Qt.CrossPattern) self.brushStyleComboBox.addItem("Backward Diagonal", Qt.BDiagPattern) self.brushStyleComboBox.addItem("Forward Diagonal", Qt.FDiagPattern) self.brushStyleComboBox.addItem("Diagonal Cross", Qt.DiagCrossPattern) self.brushStyleComboBox.addItem("Dense 1", Qt.Dense1Pattern) self.brushStyleComboBox.addItem("Dense 2", Qt.Dense2Pattern) self.brushStyleComboBox.addItem("Dense 3", Qt.Dense3Pattern) self.brushStyleComboBox.addItem("Dense 4", Qt.Dense4Pattern) self.brushStyleComboBox.addItem("Dense 5", Qt.Dense5Pattern) self.brushStyleComboBox.addItem("Dense 6", Qt.Dense6Pattern) self.brushStyleComboBox.addItem("Dense 7", Qt.Dense7Pattern) self.brushStyleComboBox.addItem("None", Qt.NoBrush) brushStyleLabel = QLabel("&Brush Style:") brushStyleLabel.setBuddy(self.brushStyleComboBox) otherOptionsLabel = QLabel("Other Options:") self.antialiasingCheckBox = QCheckBox("&Antialiasing") self.transformationsCheckBox = QCheckBox("&Transformations") self.shapeComboBox.activated.connect(self.shapeChanged) self.penWidthSpinBox.valueChanged.connect(self.penChanged) self.penStyleComboBox.activated.connect(self.penChanged) self.penCapComboBox.activated.connect(self.penChanged) self.penJoinComboBox.activated.connect(self.penChanged) self.brushStyleComboBox.activated.connect(self.brushChanged) self.antialiasingCheckBox.toggled.connect( self.renderArea.setAntialiased) self.transformationsCheckBox.toggled.connect( self.renderArea.setTransformed) mainLayout = QGridLayout() mainLayout.setColumnStretch(0, 1) mainLayout.setColumnStretch(3, 1) mainLayout.addWidget(self.renderArea, 0, 0, 1, 4) mainLayout.setRowMinimumHeight(1, 6) mainLayout.addWidget(shapeLabel, 2, 1, Qt.AlignRight) mainLayout.addWidget(self.shapeComboBox, 2, 2) mainLayout.addWidget(penWidthLabel, 3, 1, Qt.AlignRight) mainLayout.addWidget(self.penWidthSpinBox, 3, 2) mainLayout.addWidget(penStyleLabel, 4, 1, Qt.AlignRight) mainLayout.addWidget(self.penStyleComboBox, 4, 2) mainLayout.addWidget(penCapLabel, 5, 1, Qt.AlignRight) mainLayout.addWidget(self.penCapComboBox, 5, 2) mainLayout.addWidget(penJoinLabel, 6, 1, Qt.AlignRight) mainLayout.addWidget(self.penJoinComboBox, 6, 2) mainLayout.addWidget(brushStyleLabel, 7, 1, Qt.AlignRight) mainLayout.addWidget(self.brushStyleComboBox, 7, 2) mainLayout.setRowMinimumHeight(8, 6) mainLayout.addWidget(otherOptionsLabel, 9, 1, Qt.AlignRight) mainLayout.addWidget(self.antialiasingCheckBox, 9, 2) mainLayout.addWidget(self.transformationsCheckBox, 10, 2) self.setLayout(mainLayout) self.shapeChanged() self.penChanged() self.brushChanged() self.antialiasingCheckBox.setChecked(True) self.setWindowTitle("Basic Drawing")
def __init__(self, parent=None): AbstractOperationDetails.__init__(self, parent) self.name = "Trade" self.date_label = QLabel(self) self.settlement_label = QLabel() self.number_label = QLabel(self) self.account_label = QLabel(self) self.symbol_label = QLabel(self) self.qty_label = QLabel(self) self.price_label = QLabel(self) self.fee_label = QLabel(self) self.comment_label = QLabel(self) self.main_label.setText(g_tr("TradeWidget", "Buy / Sell")) self.date_label.setText(g_tr("TradeWidget", "Date/Time")) self.settlement_label.setText(g_tr("TradeWidget", "Settlement")) self.number_label.setText(g_tr("TradeWidget", "#")) self.account_label.setText(g_tr("TradeWidget", "Account")) self.symbol_label.setText(g_tr("TradeWidget", "Asset")) self.qty_label.setText(g_tr("TradeWidget", "Qty")) self.price_label.setText(g_tr("TradeWidget", "Price")) self.fee_label.setText(g_tr("TradeWidget", "Fee")) self.comment_label.setText(g_tr("TradeWidget", "Note")) self.timestamp_editor = QDateTimeEdit(self) self.timestamp_editor.setCalendarPopup(True) self.timestamp_editor.setTimeSpec(Qt.UTC) self.timestamp_editor.setFixedWidth(self.timestamp_editor.fontMetrics().width("00/00/0000 00:00:00") * 1.25) self.timestamp_editor.setDisplayFormat("dd/MM/yyyy hh:mm:ss") self.settlement_editor = QDateEdit(self) self.settlement_editor.setCalendarPopup(True) self.settlement_editor.setTimeSpec(Qt.UTC) self.settlement_editor.setFixedWidth(self.settlement_editor.fontMetrics().width("00/00/0000") * 1.5) self.settlement_editor.setDisplayFormat("dd/MM/yyyy") self.account_widget = AccountSelector(self) self.asset_widget = AssetSelector(self) self.qty_edit = AmountEdit(self) self.qty_edit.setAlignment(Qt.AlignRight) self.price_edit = AmountEdit(self) self.price_edit.setAlignment(Qt.AlignRight) self.fee_edit = AmountEdit(self) self.fee_edit.setAlignment(Qt.AlignRight) self.number = QLineEdit(self) self.comment = QLineEdit(self) self.layout.addWidget(self.date_label, 1, 0, 1, 1, Qt.AlignLeft) self.layout.addWidget(self.account_label, 2, 0, 1, 1, Qt.AlignLeft) self.layout.addWidget(self.symbol_label, 3, 0, 1, 1, Qt.AlignLeft) self.layout.addWidget(self.comment_label, 4, 0, 1, 1, Qt.AlignLeft) self.layout.addWidget(self.timestamp_editor, 1, 1, 1, 1, Qt.AlignLeft) self.layout.addWidget(self.account_widget, 2, 1, 1, 4) self.layout.addWidget(self.asset_widget, 3, 1, 1, 4) self.layout.addWidget(self.comment, 4, 1, 1, 4) self.layout.addWidget(self.settlement_label, 1, 2, 1, 1, Qt.AlignRight) self.layout.addWidget(self.settlement_editor, 1, 3, 1, 1, Qt.AlignLeft) self.layout.addWidget(self.number_label, 1, 5, 1, 1, Qt.AlignRight) self.layout.addWidget(self.qty_label, 2, 5, 1, 1, Qt.AlignRight) self.layout.addWidget(self.price_label, 3, 5, 1, 1, Qt.AlignRight) self.layout.addWidget(self.fee_label, 4, 5, 1, 1, Qt.AlignRight) self.layout.addWidget(self.number, 1, 6, 1, 1) self.layout.addWidget(self.qty_edit, 2, 6, 1, 1) self.layout.addWidget(self.price_edit, 3, 6, 1, 1) self.layout.addWidget(self.fee_edit, 4, 6, 1, 1) self.layout.addWidget(self.commit_button, 0, 8, 1, 1) self.layout.addWidget(self.revert_button, 0, 9, 1, 1) self.layout.addItem(self.verticalSpacer, 6, 6, 1, 1) self.layout.addItem(self.horizontalSpacer, 1, 6, 1, 1) super()._init_db("trades") self.mapper.setItemDelegate(TradeWidgetDelegate(self.mapper)) self.account_widget.changed.connect(self.mapper.submit) self.asset_widget.changed.connect(self.mapper.submit) self.mapper.addMapping(self.timestamp_editor, self.model.fieldIndex("timestamp")) self.mapper.addMapping(self.settlement_editor, self.model.fieldIndex("settlement")) self.mapper.addMapping(self.account_widget, self.model.fieldIndex("account_id")) self.mapper.addMapping(self.asset_widget, self.model.fieldIndex("asset_id")) self.mapper.addMapping(self.number, self.model.fieldIndex("number")) self.mapper.addMapping(self.qty_edit, self.model.fieldIndex("qty")) self.mapper.addMapping(self.price_edit, self.model.fieldIndex("price")) self.mapper.addMapping(self.fee_edit, self.model.fieldIndex("fee")) self.mapper.addMapping(self.comment, self.model.fieldIndex("note")) self.model.select()
def info(self, message: str) -> None: """ This function will show a box with a message that will fade in and then out. :param message: The message to show inside of the window :type message: str :return: None :rtype: NoneType """ # QMessageBox.information(self, title, message) label = QLabel(self) windowWidth = self.width() windowHeight = self.height() labelWidth = 700 labelHeight = 300 label.setGeometry(windowWidth / 2 - labelWidth / 2, windowHeight / 3 - labelHeight / 2, labelWidth, labelHeight) label.show() style = "border: 3px solid red;" \ "border-radius:20px;" \ "background-color:#353535;" \ "color:#dddddd" label.setStyleSheet(style) label.setAlignment(Qt.AlignCenter) label.setText(message) fadeInTimer = QTimer() waitTimer = QTimer() fadeOutTimer = QTimer() waitTimer.setSingleShot(True) waitTimer.setInterval(3000) effect = QGraphicsOpacityEffect(label) label.setGraphicsEffect(effect) effect.setOpacity(0) def fadeIn(): opacity = effect.opacity() + 0.01 effect.setOpacity(opacity) if opacity >= 1: fadeInTimer.stop() waitTimer.start() def wait(): fadeOutTimer.start(10) def fadeOut(): opacity = effect.opacity() - 0.01 effect.setOpacity(opacity) if opacity <= 0: fadeOutTimer.stop() label.hide() fadeInTimer.timeout.connect(fadeIn) waitTimer.timeout.connect(wait) fadeOutTimer.timeout.connect(fadeOut) fadeInTimer.start(10)
def __init__(self, app, appname, *args, **kwargs): super().__init__(*args, **kwargs) self.hide() #self.setMinimumSize(640, 480) self.setFixedSize(self.geometry().width(), self.geometry().height()) self.setWindowIcon(QIcon('icon.ico')) self.setWindowTitle(appname) # Create menu bar menu_bar = QMenuBar() help_menu = menu_bar.addAction('&Help') about_menu = menu_bar.addAction('A&bout') exit_menu = menu_bar.addAction('&Exit') self.setMenuBar(menu_bar) # Make interface layouts window = QWidget() layout = QVBoxLayout() top_section = QVBoxLayout() buttons = QGridLayout() middle_section = QHBoxLayout() label_section = QHBoxLayout() range_section = QGridLayout() clarity_section = QHBoxLayout() plot_section = QHBoxLayout() bottom_section = QVBoxLayout() status_layout = QHBoxLayout() # Create widgets and items figure = plt.figure() canvas = FigureCanvas(figure) label = QLabel(f'''Welcome to {appname}! Plot any equation of the form y = f(x). Use the options below to plot your own equation!''') help_message = QMessageBox() help_message.setTextFormat(Qt.RichText) help_message.setText(f'''<h3>Help</h3> {appname} lets you plot any equation of the form y = f(x). <br/> Enter the function f(x), specify the range of x, and click Plot! <br/><br/> Operators : <code>+, -, *, /</code><br/> Variable : <code>x</code><br/> Functions : <code>sin, cos, tan</code><br/> <code>pi</code> : π<br/> <code>e</code> : Exponential e<br/> <code>c</code> : Speed of Light<br/>''') help_message.setStandardButtons(QMessageBox.Ok) help_message.setWindowTitle(f'{appname} - Help') self.help = help_message help_button = QPushButton('Help...') help_button.clicked.connect(self.help.exec_) about_message = QMessageBox() about_message.setWindowTitle(f'{appname} - About') about_message.setTextFormat(Qt.RichText) about_message.setText(f'''<h3>About</h3> {appname} is created in PySide2 (Qt), using \ the Matplotlib and Equation PyPI modules for plotting and parsing expressions respectively. <br/><br/> Created by <a href="http://paramsid.com">Param Siddharth</a>.''') about_message.setStandardButtons(QMessageBox.Ok) self.about = about_message about_button = QPushButton('About...') about_button.clicked.connect(self.about.exec_) expr_label = QLabel('f(x) =') expr_input = QLineEdit() range_label1 = QLabel('Minimum (x):') range_min = QLineEdit() range_label2 = QLabel('Maximum (x):') range_max = QLineEdit() clarity_label = QLabel('Clarity:') clarity_spinbox = QSpinBox() clarity_spinbox.setRange(1, 10000) clarity_spinbox.setValue(100) plot_button = QPushButton('Plot') plot_button.setMaximumWidth(200) status = QStatusBar() status_text = QLabel('') status_text.setStyleSheet('color: #999999;') attribution = QLabel( 'Made with <span style="color: red;">❤</span> by <a href="http://paramsid.com">Param</a>' ) attribution.setTextFormat(Qt.RichText) attribution.setStyleSheet('color: #555555; font-size: 20px;') attribution.setAlignment(Qt.AlignRight | Qt.AlignVCenter) help_menu.triggered.connect(self.help.exec_) about_menu.triggered.connect(self.about.exec_) exit_menu.triggered.connect(self.close) # Configure backend backmath.configure(canvas=canvas, figure=figure, btn=plot_button, text=expr_input, limits=(range_min, range_max), status=status_text, range_text=(range_min, range_max), clarity=clarity_spinbox) # Finalize and display top_section.addWidget(canvas) buttons.addWidget(help_button, 0, 0, 1, 1) buttons.addWidget(about_button, 0, 1, 1, 1) middle_section.addWidget(label) middle_section.addLayout(buttons) label_section.addWidget(expr_label) label_section.addWidget(expr_input) equally_spaced = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) equally_spaced.setHorizontalStretch(1) range_label1.setSizePolicy(equally_spaced) range_min.setSizePolicy(equally_spaced) range_label2.setSizePolicy(equally_spaced) range_max.setSizePolicy(equally_spaced) range_label1.setAlignment(Qt.AlignRight | Qt.AlignVCenter) range_label2.setAlignment(Qt.AlignRight | Qt.AlignVCenter) range_section.addWidget(range_label1, 0, 0, 1, 1) range_section.addWidget(range_min, 0, 1, 1, 1) range_section.addWidget(range_label2, 0, 2, 1, 1) range_section.addWidget(range_max, 0, 3, 1, 1) clarity_label.setAlignment(Qt.AlignRight | Qt.AlignVCenter) clarity_section.addWidget(clarity_label) clarity_section.addWidget(clarity_spinbox) plot_section.addWidget(plot_button) status.addWidget(status_text) status.addPermanentWidget(attribution) status_layout.addWidget(status) bottom_section.addLayout(label_section) bottom_section.addLayout(range_section) bottom_section.addLayout(clarity_section) bottom_section.addLayout(plot_section) layout.addLayout(top_section) layout.addLayout(middle_section) layout.addLayout(bottom_section) layout.addLayout(status_layout) window.setLayout(layout) self.setCentralWidget(window) self.show() status_text.setText('READY ')
def __init__(self, app, parent): super().__init__(parent) self.app = app self.parent = parent self.features = FeaturesSetup() self.layout = QVBoxLayout() self.title = QLabel("Brightness", self) myFont = self.title.font() myFont.setBold(True) self.title.setFont(myFont) self.title.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter) self.title.setAlignment(QtCore.Qt.AlignCenter) self.leftButton = QPushButton(u"\U00002190 Info", self) self.leftButton.setFlat(True) self.leftButton.setStyleSheet("QPushButton { text-align: left; }") self.leftButton.clicked.connect(self.previous) self.title_layout = QHBoxLayout() self.title_layout.addWidget(self.leftButton, 1) self.rightButton = QPushButton(u"Contrast \U00002192", self) self.rightButton.setFlat(True) self.rightButton.setStyleSheet("QPushButton { text-align: right; }") self.rightButton.clicked.connect(self.next) self.title_layout.addWidget( self.title, 1, QtCore.Qt.AlignVCenter | QtCore.Qt.AlignCenter) self.title_layout.addWidget(self.rightButton, 1) self.title_layout.setContentsMargins(0, 0, 0, 0) self.title_layout.setSpacing(0) self.info_frame = QtWidgets.QFrame(self) self.info_layout = QVBoxLayout() self.info_layout.setContentsMargins(0, 0, 0, 0) self.info_layout.setSpacing(0) self.info_frame.setLayout(self.info_layout) # Initialize tab screen self.infos = QTabWidget(self.info_frame) self.info_layout.addWidget(self.infos, 1) self.setup_frame = QtWidgets.QFrame(self) self.setup_layout = QVBoxLayout() self.setup_layout.setContentsMargins(0, 0, 0, 0) self.setup_layout.setSpacing(0) self.setup_frame.setLayout(self.setup_layout) self.slider = QSlider(QtCore.Qt.Horizontal, self) slider_color = Application.Application.getAccentColor() self.slider.setStyleSheet( "QSlider::handle:horizontal {background-color: " + slider_color.name() + ";}") self.slider.setFocusPolicy(QtCore.Qt.StrongFocus) self.slider.setTickPosition(QSlider.TicksBothSides) self.slider.setRange(0, 100) self.slider.setTickInterval(10) self.slider.setPageStep(10) self.slider.setSingleStep(1) self.slider.valueChanged.connect(self.value_change) self.calibration = QLabel('{}:'.format(" Calibration"), self) self.title.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) # Initialize tab screen self.calibrations = QTabWidget(self.setup_frame) self.calibration1 = QWidget(self.calibrations) self.calibration2 = QWidget(self.calibrations) # Add calibrations self.calibrations.addTab(self.calibration1, "1: CMN") self.calibrations.addTab(self.calibration2, "2: HPN") self.tab_style_options = QtWidgets.QStyleOptionTabWidgetFrame() # self.calibrations.initStyleOption(self.tab_style_options) self.tab_style_options.initFrom(self.calibrations) print("TabColor Window {}".format( self.tab_style_options.palette.color(QtGui.QPalette.Window).name())) print("TabColor Base {}".format( self.tab_style_options.palette.color(QtGui.QPalette.Base).name())) print("TabColor AlternateBase {}".format( self.tab_style_options.palette.color(QtGui.QPalette.AlternateBase).name())) print("TabColor Button {}".format( self.tab_style_options.palette.color(QtGui.QPalette.Button).name())) print("TabColor Mid {}".format( self.tab_style_options.palette.color(QtGui.QPalette.Mid).name())) print("TabColor Midlight {}".format( self.tab_style_options.palette.color(QtGui.QPalette.Midlight).name())) print("TabColor Light {}".format( self.tab_style_options.palette.color(QtGui.QPalette.Light).name())) print("TabColor Highlight {}".format( self.tab_style_options.palette.color(QtGui.QPalette.Highlight).name())) self.tabbar_style_options = QtWidgets.QStyleOptionTab() # self.calibrations.tabBar().initStyleOption(self.tabbar_style_options, 0) self.tabbar_style_options.initFrom(self.calibrations.tabBar()) print("TabbarColor Window {}".format( self.tabbar_style_options.palette.color(QtGui.QPalette.Window).name())) print("TabbarColor Base {}".format( self.tabbar_style_options.palette.color(QtGui.QPalette.Base).name())) print("TabbarColor AlternateBase {}".format( self.tabbar_style_options.palette.color(QtGui.QPalette.AlternateBase).name())) print("TabbarColor Button {}".format( self.tabbar_style_options.palette.color(QtGui.QPalette.Button).name())) print("TabbarColor Mid {}".format( self.tabbar_style_options.palette.color(QtGui.QPalette.Mid).name())) print("TabbarColor Midlight {}".format( self.tabbar_style_options.palette.color(QtGui.QPalette.Midlight).name())) print("TabbarColor Light {}".format( self.tabbar_style_options.palette.color(QtGui.QPalette.Light).name())) print("TabbarColor Highlight {}".format( self.tabbar_style_options.palette.color(QtGui.QPalette.Highlight).name())) groupbox = QtWidgets.QGroupBox() self.groupbox_style_options = QtWidgets.QStyleOptionGroupBox() groupbox.initStyleOption(self.groupbox_style_options) # self.groupbox_style_options.initFrom(groupbox) print("GroupBox Window {}".format( self.groupbox_style_options.palette.color(QtGui.QPalette.Window).name())) print("GroupBox Base {}".format( self.groupbox_style_options.palette.color(QtGui.QPalette.Base).name())) print("GroupBox AlternateBase {}".format( self.groupbox_style_options.palette.color(QtGui.QPalette.AlternateBase).name())) print("GroupBox Button {}".format( self.groupbox_style_options.palette.color(QtGui.QPalette.Button).name())) print("GroupBox Mid {}".format( self.groupbox_style_options.palette.color(QtGui.QPalette.Mid).name())) print("GroupBox Midlight {}".format( self.groupbox_style_options.palette.color(QtGui.QPalette.Midlight).name())) print("GroupBox Light {}".format( self.groupbox_style_options.palette.color(QtGui.QPalette.Light).name())) print("GroupBox Highlight {}".format( self.groupbox_style_options.palette.color(QtGui.QPalette.Highlight).name())) r = float(self.groupbox_style_options.palette.color( QtGui.QPalette.Button).redF()) print("tab_base_color r {}".format(r)) r += (0.5 * float(self.groupbox_style_options.palette.color(QtGui.QPalette.Base).redF())) g = float(self.groupbox_style_options.palette.color( QtGui.QPalette.Button).greenF()) g += (0.5 * float(self.groupbox_style_options.palette.color(QtGui.QPalette.Base).greenF())) b = float(self.groupbox_style_options.palette.color( QtGui.QPalette.Button).blueF()) b += (0.5 * float(self.groupbox_style_options.palette.color(QtGui.QPalette.Base).blueF())) print("tab_base_color rgb {} {} {}".format(r, g, b)) self.tab_base_color = QtGui.QColor(r*255, g*255, b*255) print("tab_base_color {}".format( self.tab_base_color.name())) # sys.exit() # Create first tab self.calibration1.layout = QVBoxLayout() self.pushButton1 = QPushButton("PySide2 button", self) self.calibration1.layout.addWidget(self.pushButton1) self.calibration1.setLayout(self.calibration1.layout) # Add calibrations to widget self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) self.layout.addLayout(self.title_layout) self.layout.addWidget(self.info_frame, 1) self.layout.addWidget(self.setup_frame, 1) self.setup_layout.addWidget(self.slider) self.setup_layout.addWidget(self.calibration) self.setup_layout.addWidget(self.calibrations) self.info_frame.hide() self.setLayout(self.layout) self.init()