def iner(): initial = self.get_color(self.custom_colors[button_]) color_dialog = QColorDialog(parent=parent) try: color_dialog.setCurrentColor(initial) except: # snake_case, true_property color_dialog.current_color = initial done = color_dialog.exec_() try: color_ = color_dialog.currentColor() except: # snake_case, true_property color_ = color_dialog.current_color try: if done and color_.isValid(): rgb_255 = [color_.red(), color_.green(), color_.blue()] color = '#' + ''.join([hex(v)[2:].ljust(2, '0') for v in rgb_255]) self.custom_colors[button_] = color self.update_theme(parent) except: # snake_case, true_property if done and color_.is_valid(): rgb_255 = [color_.red(), color_.green(), color_.blue()] color = '#' + ''.join([hex(v)[2:].ljust(2, '0') for v in rgb_255]) self.custom_colors[button_] = color self.update_theme(parent)
def __change_color(self) -> None: """ Displays the color chooser dialog to select a new color, then updates this widget """ dlg = QColorDialog(self.color) if dlg.exec_(): self.color = self.closest_color(dlg.currentColor().name()) self.btn.setText(self.color.upper()) self.update_bg()
def editHighlightColor(self): current_color = self.model.activeView.highlightBackground dlg = QColorDialog(self) dlg.setCurrentColor(QtGui.QColor.fromRgb(*current_color)) if dlg.exec_(): new_color = dlg.currentColor().getRgb()[:3] self.model.activeView.highlightBackground = new_color self.colorDialog.updateHighlightColor()
def pick_color(self): # This should only be called by signals/slots # It uses the sender() to get the button that called it sender = self.sender() color = sender.text() dialog = QColorDialog(QColor(color), self.ui) if dialog.exec_(): sender.setText(dialog.selectedColor().name()) self.update_button_colors() self.update_config()
def iner(): initial = self.get_color(self.custom_colors[button_]) color_dialog = QColorDialog(parent=parent) color_dialog.setCurrentColor(initial) done = color_dialog.exec_() color_ = color_dialog.currentColor() if done and color_.isValid(): color = '#' + ''.join([hex(v)[2:].ljust(2, '0') for v in color_.toTuple()[:3]]) self.custom_colors[button_] = color self.update_theme(parent)
def pick_line_color(self): sender = self.sender() color = sender.text() dialog = QColorDialog(QColor(color), self.ui) if dialog.exec_(): sender.setText(dialog.selectedColor().name()) lc = self.ui.line_color lc.setStyleSheet('QPushButton {background-color: %s}' % lc.text()) self.outline_color = dialog.selectedColor().name() self.update_template_style()
def editOverlapColor(self, apply=False): current_color = self.model.activeView.overlap_color dlg = QColorDialog(self) dlg.setCurrentColor(QtGui.QColor.fromRgb(*current_color)) if dlg.exec_(): new_color = dlg.currentColor().getRgb()[:3] self.model.activeView.overlap_color = new_color self.colorDialog.updateOverlapColor() if apply: self.applyChanges()
def editBackgroundColor(self, apply=False): current_color = self.model.activeView.domainBackground dlg = QColorDialog(self) dlg.setCurrentColor(QtGui.QColor.fromRgb(*current_color)) if dlg.exec_(): new_color = dlg.currentColor().getRgb()[:3] self.model.activeView.domainBackground = new_color self.colorDialog.updateBackgroundColor() if apply: self.applyChanges()
def editDomainColor(self, kind, id): if kind == 'Cell': domain = self.model.activeView.cells else: domain = self.model.activeView.materials current_color = domain[id].color dlg = QColorDialog(self) if isinstance(current_color, tuple): dlg.setCurrentColor(QtGui.QColor.fromRgb(*current_color)) elif isinstance(current_color, str): current_color = openmc.plots._SVG_COLORS[current_color] dlg.setCurrentColor(QtGui.QColor.fromRgb(*current_color)) if dlg.exec_(): new_color = dlg.currentColor().getRgb()[:3] domain[id].color = new_color self.applyChanges()
def boxClicked(self): dialog = QColorDialog() if dialog.exec_(): self.setColorText(dialog.selectedColor().name())