def create_button(text='', layout=None, tooltip=None, icon=None, enabled=True, default=False): """Create a button, set its title, and add it to the parent.""" button = QtWidgets.QPushButton() button.setCursor(Qt.PointingHandCursor) if text: button.setText(text) if icon is not None: button.setIcon(icon) button.setIconSize(QtCore.QSize(defs.small_icon, defs.small_icon)) if tooltip is not None: button.setToolTip(tooltip) if layout is not None: layout.addWidget(button) if not enabled: button.setEnabled(False) if default: button.setDefault(True) return button
def mousePressEvent(self, event): super(ImageView, self).mousePressEvent(event) button = event.button() modifier = event.modifiers() # pan if modifier == Qt.ControlModifier and button == Qt.LeftButton: self.start_drag = event.pos() self.panning = True # initiate/show ROI selection if modifier == Qt.ShiftModifier and button == Qt.LeftButton: self.start_drag = event.pos() if self.rubberband is None: self.rubberband = QtWidgets.QRubberBand( QtWidgets.QRubberBand.Rectangle, self.viewport()) self.rubberband.setGeometry( QtCore.QRect(self.start_drag, QtCore.QSize())) self.rubberband.show()
def main(): args, extra_args = _parse_arguments() try: os.makedirs("logs") except os.error as err: # It's OK if the log directory exists. This is to be compatible with Python 2.7 if err.errno != errno.EEXIST: raise err logging.basicConfig(level=logging.INFO, filename=os.path.join("logs", "timechart.log"), format="[%(asctime)s] [%(levelname)-8s] - %(message)s") logger = logging.getLogger('') console_handler = logging.StreamHandler() console_handler.setFormatter(logging.Formatter("%(message)s")) logger.addHandler(console_handler) if args.log_level: logger.setLevel(args.log_level) console_handler.setLevel(args.log_level) base_path = os.path.dirname(os.path.realpath(__file__)) icon_path_mask = os.path.join(base_path, "icons", "charts_{}.png") app = PyDMApplication(hide_nav_bar=True, hide_menu_bar=True, hide_status_bar=True, use_main_window=False) app_icon = QtGui.QIcon() app_icon.addFile(icon_path_mask.format(16), QtCore.QSize(16, 16)) app_icon.addFile(icon_path_mask.format(24), QtCore.QSize(24, 24)) app_icon.addFile(icon_path_mask.format(32), QtCore.QSize(32, 32)) app_icon.addFile(icon_path_mask.format(64), QtCore.QSize(64, 64)) app_icon.addFile(icon_path_mask.format(128), QtCore.QSize(128, 128)) app_icon.addFile(icon_path_mask.format(256), QtCore.QSize(256, 256)) app.setWindowIcon(app_icon) config_file = None if args.config_file: config_file = os.path.expandvars(os.path.expanduser(args.config_file)) display = TimeChartDisplay(config_file=config_file, args=extra_args) display.show() sys.exit(app.exec_())
def load_icon() -> QtGui.QIcon: """ Loads the time capture icons. :return app_icon """ app_icon = QtGui.QIcon() app_icon.addFile("assets/icons/16x16.jpeg", QtCore.QSize(16, 16)) app_icon.addFile("assets/icons/24x24.jpeg", QtCore.QSize(24, 24)) app_icon.addFile("assets/icons/32x32.jpeg", QtCore.QSize(32, 32)) app_icon.addFile("assets/icons/48x48.jpeg", QtCore.QSize(48, 48)) app_icon.addFile("assets/icons/64x64.jpeg", QtCore.QSize(64, 64)) app_icon.addFile("assets/icons/128x128.png", QtCore.QSize(128, 128)) return app_icon
def GetQtPixmap(self, clip_rect=None, target_resolution=None): (my_width, my_height) = self._resolution if clip_rect is None: clip_rect = QC.QRect(QC.QPoint(0, 0), QC.QSize(my_width, my_height)) if target_resolution is None: target_resolution = clip_rect.size() my_full_rect = QC.QRect(0, 0, my_width, my_height) if my_full_rect.contains(clip_rect): try: numpy_image = self._GetNumPyImage(clip_rect, target_resolution) (height, width, depth) = numpy_image.shape data = numpy_image.data return HG.client_controller.bitmap_manager.GetQtPixmapFromBuffer( width, height, depth * 8, data) except Exception as e: HydrusData.PrintException(e, do_wait=False) HydrusData.Print( 'Failed to produce a tile! Info is: {}, {}, {}, {}'.format( self._hash.hex(), (my_width, my_height), clip_rect, target_resolution)) pixmap = QG.QPixmap(target_resolution) pixmap.fill(QC.Qt.black) return pixmap
def _init_toolbar(self): for text, tooltip_text, mdi_icon, callback, checked in self.toolitems: if text is None: self.addSeparator() else: if mdi_icon: action = self.addAction(get_icon(mdi_icon), text, getattr(self, callback)) else: action = self.addAction(text, getattr(self, callback)) self._actions[callback] = action if checked is not None: action.setCheckable(True) action.setChecked(checked) if tooltip_text is not None: action.setToolTip(tooltip_text) dpi_ratio = QtWidgets.QApplication.instance().desktop().physicalDpiX( ) / 100 self.setIconSize(QtCore.QSize(24 * dpi_ratio, 24 * dpi_ratio))
def __init__(self, label=None, icon=None): super(ProjectManagerInitButton, self).__init__() self.setIcon(QtGui.QIcon(icon)) self.setText(label) self.setMinimumSize(130, 80) self.setIconSize(QtCore.QSize(42, 42)) self.setCursor(QtCore.Qt.PointingHandCursor) self.setStyleSheet(""" QPushButton{ background: none; border: 3px solid #a6a6a6; border-radius: 15px; font: 20px; padding: 10px; } QPushButton::hover{ background: #3e3e3e; border: 3px solid #148CD2 } """)
def sizeHint(self, option, index): i_dataType = None i_model = index.model() if i_model: i_dataType = i_model.dataType(index) size = index.data(QtCore.Qt.SizeHintRole) if not size: option4 = QtWidgets.QStyleOptionViewItem(option) self.initStyleOption(option4, index, model=i_model, dataType=i_dataType) style = self._view.style() size = style.sizeFromContents(QtWidgets.QStyle.CT_ItemViewItem, option4, QtCore.QSize(), self._view) if i_model and i_dataType == common.TYPE_IMAGE and index.data(QtCore.Qt.DisplayRole): imageHeight = int(self._view.header().sectionSize( index.column()) / self.__imageCellAspectRatio) # give the cell a 16/9 aspect ratio if imageHeight > size.height(): size.setHeight(imageHeight) return size if isinstance(size, QtCore.QSize) else size.toSize()
def __init__(self, parent=None): super(GraphView, self).__init__(parent) self.setObjectName('graphView') self.__graphViewWidget = parent self.setRenderHint(QtGui.QPainter.Antialiasing) self.setRenderHint(QtGui.QPainter.TextAntialiasing) self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) # Explicitly set the scene rect. This ensures all view parameters will be explicitly controlled # in the event handlers of this class. size = QtCore.QSize(600, 400); self.resize(size) self.setSceneRect(-size.width() * 0.5, -size.height() * 0.5, size.width(), size.height()) self.setAcceptDrops(True) self.reset()
def __init__(self, app: FastFlixApp, **kwargs): super().__init__(None) self.app = app self.pb = None self.logs = Logs() self.changes = Changes() self.about = None self.profile_details = None self.init_menu() self.main = Main(self, app) self.profile = ProfileWindow(self.app, self.main) self.setCentralWidget(self.main) self.setMinimumSize(QtCore.QSize(1280, 700)) self.icon = QtGui.QIcon(main_icon) self.setWindowIcon(self.icon) self.main.set_profile()
def guirestore(widget, qsettings, default): logger.info("Restoring settings: {}".format(qsettings.fileName())) # Restore geometry selfName = widget.objectName() qsettings.beginGroup("mainwindow") try: widget.resize( qsettings.value(selfName + "_size", QtCore.QSize(500, 500))) widget.move(qsettings.value(selfName + "_pos", QtCore.QPoint(60, 60))) except Exception: pass for name, obj in inspect.getmembers(widget): try: _, setter, _ = getter_setter_onchange(obj) value = qsettings.value(name, default.value(name)) setter(value) if value not in (None, "") else None except Exception: logger.warn( "Unable to restore settings for object: {}".format(name)) qsettings.endGroup()
def GetQtImage(self, clip_rect=None, target_resolution=None): if clip_rect is None: (width, height) = self._resolution clip_rect = QC.QRect(QC.QPoint(0, 0), QC.QSize(width, height)) if target_resolution is None: target_resolution = clip_rect.size() numpy_image = self._GetNumPyImage(clip_rect, target_resolution) (height, width, depth) = numpy_image.shape data = numpy_image.data return HG.client_controller.bitmap_manager.GetQtImageFromBuffer( width, height, depth * 8, data)
def element_size(self, element): """ desc: Determines the size of a list element. Uses previously determined size if available, to improve performance. arguments: element: desc: The element to determine the size for. type: QListWidgetItem returns: type: QSize """ if self._element_size is None: self._element_size = QtCore.QSize( self.ui.items_list_widget.size().width(), element.minimumSizeHint().height()) return self._element_size
def add_test(self, fname): """Add new test""" if self.test_nb is None: self.test_nb = 0 self.test_nb += 1 row = (self.test_nb - 1) % self.ROWS column = (self.test_nb - 1) // self.ROWS bname = osp.basename(fname) button = QW.QToolButton(self) button.setToolButtonStyle(QC.Qt.ToolButtonTextUnderIcon) shot = osp.join(TEST_PATH, "data", bname.replace(".py", ".png")) if osp.isfile(shot): button.setIcon(QG.QIcon(shot)) else: button.setIcon(self.get_std_icon("DialogYesButton")) button.setText(bname) button.setToolTip(fname) button.setIconSize(QC.QSize(130, 80)) button.clicked.connect(lambda checked=None, fname=fname: run_test(fname)) self.grid_layout.addWidget(button, row, column)
def _GetRatingFromClickEvent( self, event ): click_pos = event.pos() x = event.pos().x() y = event.pos().y() BORDER = 1 my_active_size = self.size() - QC.QSize( BORDER * 2, BORDER * 2 ) adjusted_click_pos = click_pos - QC.QPoint( BORDER, BORDER ) my_active_rect = QC.QRect( QC.QPoint( 0, 0 ), my_active_size ) if my_active_rect.contains( adjusted_click_pos ): x_adjusted = x - BORDER proportion_filled = x_adjusted / my_active_size.width() if self._allow_zero: stars = round( proportion_filled * self._num_stars ) else: stars = int( proportion_filled * self._num_stars ) if proportion_filled <= 1.0: stars += 1 rating = self._service.ConvertStarsToRating( stars ) return rating return None
def ExpandTLWIfPossible( tlw: QW.QWidget, frame_key, desired_size_delta: QC.QSize ): new_options = HG.client_controller.new_options ( remember_size, remember_position, last_size, last_position, default_gravity, default_position, maximised, fullscreen ) = new_options.GetFrameLocation( frame_key ) if not tlw.isMaximized() and not tlw.isFullScreen(): current_size = tlw.size() current_width = current_size.width() current_height = current_size.height() desired_delta_width = desired_size_delta.width() desired_delta_height = desired_size_delta.height() desired_width = current_width if desired_delta_width > 0: desired_width = current_width + desired_delta_width + FUZZY_PADDING desired_height = current_height if desired_delta_height > 0: desired_height = current_height + desired_delta_height + FUZZY_PADDING desired_size = QC.QSize( desired_width, desired_height ) new_size = GetSafeSize( tlw, desired_size, default_gravity ) if new_size.width() > current_width or new_size.height() > current_height: tlw.resize( new_size ) #tlw.setMinimumSize( tlw.sizeHint() ) SlideOffScreenTLWUpAndLeft( tlw )
def addComponents(self): """Add widgets to the main window. The main window contains a databases tree view, a workspace and a console. """ self.setIconSize(QtCore.QSize(22, 22)) self.setWindowIcon(self.icons_dictionary['vitables_wm']) central_widget = QtWidgets.QWidget(self) central_layout = QtWidgets.QVBoxLayout(central_widget) # Divide the top region of the window into 2 regions and put there # the workspace. The tree of databases will be added later on self.hsplitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal, central_widget) self.hsplitter.setObjectName('hsplitter') central_layout.addWidget(self.hsplitter) self.setCentralWidget(central_widget) self.hsplitter.addWidget(self.dbs_tree_view) self.workspace = QtWidgets.QMdiArea(self.hsplitter) sb_as_needed = QtCore.Qt.ScrollBarAsNeeded self.workspace.setHorizontalScrollBarPolicy(sb_as_needed) self.workspace.setVerticalScrollBarPolicy(sb_as_needed) self.workspace.setWhatsThis( translate( 'VTGUI', """<qt> <h3>The Workspace</h3> This is the area where open leaves of the object tree are displayed. Many tables and arrays can be displayed simultaneously. <p>The diferent views can be tiled as a mosaic or stacked as a cascade. </qt>""", 'WhatsThis help for the workspace')) # The signal mapper used to keep the the Window menu updated self.window_mapper = QtCore.QSignalMapper(self) self.window_mapper.mapped[QtWidgets.QWidget].connect( self.workspace.setActiveSubWindow) self.workspace.installEventFilter(self) self.dbs_tree_view.clicked.connect(self.selection_changed)
def addButton(self, function, name=None, icon=None, icon_size = (20,20), description=None, shortcut = None, checkable = False): """Create a new button in the area. Parameters ---------- function: function Function that is called when the button is clicked. name: str = None If no icon is set, the button will have this text icon: str = None Filename of the icon installed into the icon path icon_size: tuple = (20,20) Size of the icon in the button description: str = None Optional, tooltip for the button shortcut: str = None Optional, set shortcut for the button """ assert (name or icon), "Button needs name or icon" btn = QtWidgets.QPushButton() if not icon: btn.setText(name) else: from ngsgui.icons import location as icon_path btn.setIcon(QtGui.QIcon(icon_path + "/" + icon)) btn.setIconSize(QtCore.QSize(*icon_size)) if description: btn.setToolTip(description) btn.clicked.connect(function) if shortcut: btn.setShortcut(shortcut) if checkable: btn.setCheckable(True) self.layout().addWidget(btn)
def updateSizeHint(self, visible_items=2): treeWidth = self.tree.maximumViewportSize().width() # reduce treeHeight by header height treeHeight = self.tree.maximumViewportSize().height( ) - self.tree.header().height() if len(self.data_table) > 0: if len(self.data_table) <= (visible_items + 1): # limit size to show other sets treeHeight -= self.collapsedItemHeight * ( len(self.data_table) - 1) else: treeHeight -= self.collapsedItemHeight * visible_items for n, L2 in enumerate(self.L2): tableWidth = self.data_table[n].getSize().width() tableHeight = self.data_table[n].getSize().height( ) + self.collapsedItemHeight # tableHeight = self.tree.itemsSizeHint().height() width = np.min([treeWidth, tableWidth]) height = np.min([treeHeight, tableHeight]) L2.setSizeHint(0, QtCore.QSize(width, height))
def setup_docks(self): for dock in self.detector.viewer_docks: self.detector.dockarea.moveDock(dock, 'right', self.led_control.dock_manual) self.dockarea.moveDock(self.led_control.dock_sequence, 'bottom', self.led_control.dock_manual) self.dockarea.moveDock(self.steps_sequencer.dock, 'bottom', self.led_control.dock_manual) self.dockarea.moveDock(self.manual_actuation.dock, 'right', self.led_control.dock_manual) self.show_dashboard(False) QtWidgets.QApplication.processEvents() self.steps_sequencer.dock.resize(QtCore.QSize(350, 100)) self.scan_live_dock = Dock('Live Scan Plot') widget = QtWidgets.QWidget() self.scan_live_viewer = Viewer1D(widget) self.scan_live_dock.addWidget(widget) self.dockarea.addDock(self.scan_live_dock, 'bottom', self.detector.viewer_docks[0]) self.scan_live_dock.setVisible(False)
def _addButton(self, icon, willHaveMenu, L): # Create button button = QtWidgets.QToolButton(self) L.append(button) # Customize appearance if icon: button.setIcon(icon) button.setIconSize(QtCore.QSize(16, 16)) button.setStyleSheet("QToolButton { border: none; padding: 0px; }") #button.setStyleSheet("QToolButton { border: none; padding: 0px; background-color:red;}"); # Set behavior button.setCursor(QtCore.Qt.ArrowCursor) button.setPopupMode(button.InstantPopup) # Customize alignment if willHaveMenu: button.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) if sys.platform.startswith('win'): button.setText(' ') # Update self self._updateGeometry() return button
def __init__(self, *args): super(PaletteItemList, self).__init__(*args) self.owner = None self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.setColumnCount(2) self.setColumnWidth(0, 60) self.setColumnWidth(1, -1) self.setIndentation(0) self.setAttribute(Qt.WA_MacShowFocusRect, False) self.setHeaderHidden(True) self.setIconSize(QtCore.QSize(16, 16)) self.colorItemDelegate = ColorItemDelegate() self.colorItemDelegate.tree = self self.setItemDelegateForColumn(0, self.colorItemDelegate) self.dataToItem = {} self.itemSelectionChanged.connect(self.onItemSelectionChanged) self.itemClicked.connect(self.onItemClicked) self.itemChanged.connect(self.onItemChanged)
def __init__(self, text="Enter object label", parent=None, labels=None, sort_labels=True, show_text_field=True): super(LabelDialog, self).__init__(parent) self.parent = parent self.uuid = QtWidgets.QLabel('uuid') self.label = QtWidgets.QLabel('Label') self.bnr_type = QtWidgets.QLabel('Type') self.cust_display_name = QtWidgets.QLabel('Customer Display Name') self.pts_display = QtWidgets.QLabel('Points') self.uuid_edit = QtWidgets.QLineEdit() self.label_edit = QtWidgets.QLineEdit() self.bnr_type_edit = QtWidgets.QLineEdit() self.cust_display_name_edit = QtWidgets.QLineEdit() self.cust_display_name_edit.editingFinished.connect(self.postProcess) self.pts_display_edit = QtWidgets.QLineEdit() grid = QtWidgets.QGridLayout() grid.setSpacing(10) grid.addWidget(self.uuid, 1, 0) grid.addWidget(self.uuid_edit, 1, 1) grid.addWidget(self.label, 2, 0) grid.addWidget(self.label_edit, 2, 1) grid.addWidget(self.bnr_type, 3, 0) grid.addWidget(self.bnr_type_edit, 3, 1) grid.addWidget(self.cust_display_name, 4, 0) grid.addWidget(self.cust_display_name_edit, 4, 1) grid.addWidget(self.pts_display, 5, 0) grid.addWidget(self.pts_display_edit, 5, 1) # buttons self.buttonBox = bb = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self, ) bb.button(bb.Ok).setIcon(newIcon('done')) bb.button(bb.Cancel).setIcon(newIcon('undo')) bb.accepted.connect(self.validate) bb.rejected.connect(self.reject) grid.addWidget(bb, 6,0) self.setLayout(grid) self.resize(QtCore.QSize(600,400))
def style_widgets(self): mode_btn_width = 27 mode_btn_height = 130 self.calibration_mode_btn.setMaximumWidth(mode_btn_width) self.mask_mode_btn.setMaximumWidth(mode_btn_width) self.integration_mode_btn.setMaximumWidth(mode_btn_width) self.calibration_mode_btn.setMinimumHeight(mode_btn_height) self.mask_mode_btn.setMinimumHeight(mode_btn_height) self.integration_mode_btn.setMinimumHeight(mode_btn_height) button_height = 30 button_width = 30 self.show_configuration_menu_btn.setMinimumHeight(button_height) self.show_configuration_menu_btn.setMaximumHeight(button_height) self.show_configuration_menu_btn.setMinimumWidth(button_width) self.show_configuration_menu_btn.setMaximumWidth(button_width) icon_size = QtCore.QSize(20, 20) self.save_btn.setIcon(QtGui.QIcon(os.path.join(icons_path, 'save.ico'))) self.save_btn.setIconSize(icon_size) self.save_btn.setMinimumHeight(button_height) self.save_btn.setMaximumHeight(button_height) self.save_btn.setMinimumWidth(button_width) self.save_btn.setMaximumWidth(button_width) self.load_btn.setIcon(QtGui.QIcon(os.path.join(icons_path, 'open.ico'))) self.load_btn.setIconSize(icon_size) self.load_btn.setMinimumHeight(button_height) self.load_btn.setMaximumHeight(button_height) self.load_btn.setMinimumWidth(button_width) self.load_btn.setMaximumWidth(button_width) self.reset_btn.setIcon(QtGui.QIcon(os.path.join(icons_path, 'reset.ico'))) self.reset_btn.setIconSize(icon_size) self.reset_btn.setMinimumHeight(button_height) self.reset_btn.setMaximumHeight(button_height) self.reset_btn.setMinimumWidth(button_width) self.reset_btn.setMaximumWidth(button_width)
def _setup_widgets(self): self.layout = QtWidgets.QFormLayout() self.size_widget = QtWidgets.QSpinBox() self.size_widget.setMinimum(1) self.size_widget.setMaximum(40) self.size_widget.setValue(self.layer.style.markersize) self.label_widget = QtWidgets.QLineEdit() self.label_widget.setText(self.layer.label) self.label_widget.selectAll() self.symbol_widget = QtWidgets.QComboBox() for idx, symbol in enumerate(self._symbols): icon = symbol_icon(symbol) self.symbol_widget.addItem(icon, '') if symbol is self.layer.style.marker: self.symbol_widget.setCurrentIndex(idx) self.symbol_widget.setIconSize(QtCore.QSize(20, 20)) self.symbol_widget.setMinimumSize(10, 32) self.color_widget = ColorWidget() self.color_widget.setStyleSheet('ColorWidget {border: 1px solid;}') color = self.layer.style.color color = mpl_to_qt4_color(color, alpha=self.layer.style.alpha) self.set_color(color) self.okcancel = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) if self._edit_label: self.layout.addRow("Label", self.label_widget) self.layout.addRow("Symbol", self.symbol_widget) self.layout.addRow("Color", self.color_widget) self.layout.addRow("Size", self.size_widget) self.layout.addWidget(self.okcancel) self.setLayout(self.layout) self.layout.setContentsMargins(6, 6, 6, 6)
def _add_buttons(self, workflows: List[WorkflowDefinition]): """ Add all buttons given a List of WorkflowDefinitions """ for workflow in workflows: # Some images are RGBA and others are Grayscale # TODO?: convert all images to RBGA pre: np.ndarray = workflow.thumbnail_pre post: np.ndarray = workflow.thumbnail_post # TODO: We need a way to a) track dimension order if present in metadata and b) try to guess dimension order color_channel_size: int = min(np.shape(workflow.thumbnail_pre)) min_index: int = np.shape(workflow.thumbnail_pre).index(color_channel_size) # If RGBA convert to grayscale if len(workflow.thumbnail_pre.shape) > 2: # cv2 expects color channel dim to be last index pre = cv2.cvtColor(np.moveaxis(workflow.thumbnail_pre, min_index, -1), cv2.COLOR_RGBA2GRAY) if len(workflow.thumbnail_post.shape) > 2: # cv2 expects color channel dim to be last index post = cv2.cvtColor(np.moveaxis(workflow.thumbnail_post, min_index, -1), cv2.COLOR_RGBA2GRAY) # Stitch Image image_stitched: np.ndarray = np.hstack([pre, post]) button: QPushButton = QPushButton("") # Get np image into QPixmap image: QPixmap = QPixmap( QImage(image_stitched.data, image_stitched.shape[1], image_stitched.shape[0], QImage.Format_Indexed8) ) button.setIcon(QIcon(image)) button.setIconSize(QtCore.QSize(PAGE_CONTENT_WIDTH - 40, 200)) button.setFixedSize(PAGE_CONTENT_WIDTH, 200) button.setToolTip(workflow.name) button.setEnabled(False) button.setObjectName(workflow.name) button.clicked.connect(self._workflow_button_clicked) self.layout().addWidget(button)
def init_dhdr10_info(self): layout = self._add_file_select( label="HDR10+ Metadata", widget_name="hdr10plus_metadata", button_action=lambda: self.dhdr10_update(), tooltip="dhdr10_info: Path to HDR10+ JSON metadata file", ) self.labels["hdr10plus_metadata"].setFixedWidth(200) self.extract_button = QtWidgets.QPushButton(t("Extract HDR10+")) self.extract_button.hide() self.extract_button.clicked.connect(self.extract_hdr10plus) self.extract_label = QtWidgets.QLabel(self) self.extract_label.hide() self.movie = QtGui.QMovie(loading_movie) self.movie.setScaledSize(QtCore.QSize(25, 25)) self.extract_label.setMovie(self.movie) layout.addWidget(self.extract_button) layout.addWidget(self.extract_label) return layout
def __init__(self, parent=None): super(ConfigDialog, self).__init__(parent) self.contentsWidget = QtWidgets.QListWidget() self.contentsWidget.setViewMode(QtWidgets.QListView.IconMode) self.contentsWidget.setIconSize(QtCore.QSize(96, 84)) self.contentsWidget.setMovement(QtWidgets.QListView.Static) self.contentsWidget.setMaximumWidth(128) self.contentsWidget.setSpacing(12) self.pagesWidget = QtWidgets.QStackedWidget() self.pagesWidget.addWidget(ConfigurationPage()) self.pagesWidget.addWidget(UpdatePage()) self.pagesWidget.addWidget(QueryPage()) closeButton = QtWidgets.QPushButton("Close") self.createIcons() self.contentsWidget.setCurrentRow(0) closeButton.clicked.connect(self.close) horizontalLayout = QtWidgets.QHBoxLayout() horizontalLayout.addWidget(self.contentsWidget) horizontalLayout.addWidget(self.pagesWidget, 1) buttonsLayout = QtWidgets.QHBoxLayout() buttonsLayout.addStretch(1) buttonsLayout.addWidget(closeButton) mainLayout = QtWidgets.QVBoxLayout() mainLayout.addLayout(horizontalLayout) mainLayout.addStretch(1) mainLayout.addSpacing(12) mainLayout.addLayout(buttonsLayout) self.setLayout(mainLayout) self.setWindowTitle("Config Dialog")
def init_rotate(self): self.rotate_combo_box = QtWidgets.QComboBox() no_rot_file = str(Path(pkg_resources.resource_filename(__name__, f"../data/rotations/FastFlix.png")).resolve()) rot_90_file = str( Path(pkg_resources.resource_filename(__name__, f"../data/rotations/FastFlix C90.png")).resolve() ) rot_270_file = str( Path(pkg_resources.resource_filename(__name__, f"../data/rotations/FastFlix CC90.png")).resolve() ) rot_180_file = str( Path(pkg_resources.resource_filename(__name__, f"../data/rotations/FastFlix 180.png")).resolve() ) self.rotate_combo_box.addItems(["No Rotation", "90°", "180°", "270°"]) self.rotate_combo_box.setItemIcon(0, QtGui.QIcon(no_rot_file)) self.rotate_combo_box.setItemIcon(1, QtGui.QIcon(rot_90_file)) self.rotate_combo_box.setItemIcon(2, QtGui.QIcon(rot_180_file)) self.rotate_combo_box.setItemIcon(3, QtGui.QIcon(rot_270_file)) self.rotate_combo_box.setIconSize(QtCore.QSize(35, 35)) self.rotate_combo_box.currentIndexChanged.connect(lambda: self.page_update()) return self.rotate_combo_box
def init_flip(self): self.flip_combo_box = QtWidgets.QComboBox() no_rot_file = str(Path(pkg_resources.resource_filename(__name__, f"../data/rotations/FastFlix.png")).resolve()) vert_flip_file = str( Path(pkg_resources.resource_filename(__name__, f"../data/rotations/FastFlix VF.png")).resolve() ) hoz_flip_file = str( Path(pkg_resources.resource_filename(__name__, f"../data/rotations/FastFlix HF.png")).resolve() ) rot_180_file = str( Path(pkg_resources.resource_filename(__name__, f"../data/rotations/FastFlix 180.png")).resolve() ) self.flip_combo_box.addItems(["No Flip", "Vertical Flip", "Horizontal Flip", "Vert + Hoz Flip"]) self.flip_combo_box.setItemIcon(0, QtGui.QIcon(no_rot_file)) self.flip_combo_box.setItemIcon(1, QtGui.QIcon(vert_flip_file)) self.flip_combo_box.setItemIcon(2, QtGui.QIcon(hoz_flip_file)) self.flip_combo_box.setItemIcon(3, QtGui.QIcon(rot_180_file)) self.flip_combo_box.setIconSize(QtCore.QSize(35, 35)) self.flip_combo_box.currentIndexChanged.connect(lambda: self.page_update()) return self.flip_combo_box