def style_sheet(self): """QSS style sheet for current theme.""" with warnings.catch_warnings(): warnings.simplefilter("ignore", FutureWarning) theme = get_theme(self.theme_name) # TODO understand qss overwrite mechanism return napari_template( "\n".join(register.qss_list) + get_stylesheet() + "\n".join(register.qss_list), **theme)
def warn_box(self, message: str, title: str, one_option=False): """ Display a warning box """ box = QMessageBox() box.setText(message) box.setWindowTitle(title) box.setStyleSheet(get_stylesheet(self.viewer.get_theme())) if one_option: box.setStandardButtons(QMessageBox.Cancel) else: box.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) return box.exec_()
def warn_images_created(self, count: int) -> None: """ Create a popup to warn a user that they will be creating a large number of layers by running a sweep. Params: count (int): number of images that user will create for warning """ message: QMessageBox = QMessageBox() message.setText(f"{int(count)} result image layers will be created.") message.setStyleSheet( get_stylesheet(self.controller.viewer.get_theme())) message.setWindowTitle("Running Sweep") message.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) return message.exec_()
def __init__(self, param_set: Dict[str, Any], step_number, controller): super().__init__() # Track UI elements self.live_count: QLabel = None self.progress_bar: QProgressBar = None self.inputs: Dict[str, QFrame] = dict() self.default_sweep_values: Dict = dict() self.layout: QVBoxLayout = QVBoxLayout() # State self.controller = controller self.step_number: int = step_number self.param_set: Dict[str, Any] = param_set rows: List[FormRow] = self._create_sweep_ui() # Format UI on init self.layout.setContentsMargins(0, 0, 0, 0) self.layout.addWidget(self._create_buttons()) self.setLayout(Form(rows)) self.setStyleSheet(get_stylesheet(self.controller.viewer.get_theme())) self.setWindowTitle("Parameter Sweep")
def _update_theme(self, event=None): """Update the napari GUI theme.""" from napari.qt import get_stylesheet from napari.utils.theme import get_theme, template # qtconsole unfortunately won't inherit the parent stylesheet # so it needs to be directly set raw_stylesheet = get_stylesheet() # template and apply the primary stylesheet # (should probably be done by napari) theme = get_theme(self.viewer.theme) self.style_sheet = template(raw_stylesheet, **theme) # After napari 0.4.6 the following syntax will be allowed # self.style_sheet = get_stylesheet(self.viewer.theme) # Set syntax styling and highlighting using theme self.syntax_style = theme["syntax_style"] bracket_color = QColor(*str_to_rgb(theme["highlight"])) self._bracket_matcher.format.setBackground(bracket_color)
def _update_theme(self, event=None): """Update the napari GUI theme.""" from napari.utils.theme import get_theme, template from napari.qt import get_stylesheet # qtconsole unfortunately won't inherit the parent stylesheet # so it needs to be directly set raw_stylesheet = get_stylesheet() # template and apply the primary stylesheet # (should probably be done by napari) # After napari 0.4.11, themes are evented models rather than # dicts. with warnings.catch_warnings(): warnings.simplefilter("ignore", FutureWarning) theme = get_theme(self.viewer.theme) self.style_sheet = template(raw_stylesheet, **theme) # After napari 0.4.6 the following syntax will be allowed # self.style_sheet = get_stylesheet(self.viewer.theme) # Set syntax styling and highlighting using theme self.syntax_style = theme['syntax_style'] bracket_color = QColor(*str_to_rgb(theme['highlight'])) self._bracket_matcher.format.setBackground(bracket_color)