def setCorkColor(self): color = QColor(settings.corkBackground["color"]) self.colorDialog = QColorDialog(color, self) color = self.colorDialog.getColor(color) if color.isValid(): settings.corkBackground["color"] = color.name() self.updateCorkColor() # Update Cork view self.mw.mainEditor.updateCorkBackground()
def color(self): ''' Avaa väri-ikkunan värin valitsemiseen ''' dialog = QColorDialog() newcolor = dialog.getColor() selectedItems = self.piirtoalusta.scene.selectedItems() command = CommandColor(self.piirtoalusta.draw, selectedItems, newcolor) self.piirtoalusta.undoStack.push(command)
def tableWidgetCellDoubleClicked(self, row, column): if column == 1: self.selected_row = row selected_item = self.tableWidget.item(self.selected_row, 1) color_dialog = QColorDialog(selected_item.data(Qt.BackgroundRole), self) color_dialog.currentColorChanged.connect(self.currentColorChanged) color_dialog.open()
def changeColor(self, *args): # show color dialog color = QColorDialog().getColor(self.val) # change mode to non transparent self.isTransparent = False # change value self.setValue(color)
def cp(): cd = QColorDialog(parent=vis.get_main_window()) cd.setWindowFlag(Qt.WindowStaysOnTopHint, True) cd.setOptions(QColorDialog.ShowAlphaChannel) cd.setCurrentColor(QColor.fromRgbF(*vis.get_added_matter_color())) cd.exec() if cd.result() == 1: vis.set_added_matter_color((cd.selectedColor().getRgbF()))
def ChangeCol(): qcd = QColorDialog(dialog) qcd.setWindowTitle('颜色选择') qcd.setCurrentColor(self.buttonColorVal) if qcd.exec() == QDialog.Accepted: self.buttonColorVal = qcd.selectedColor() self.buttonColor.setStyleSheet( 'QWidget {background-color:%s}' % self.buttonColorVal.name())
def mouseDoubleClickEvent(self, event): if self._readOnly: return dialog = QColorDialog(self._color) dialog.setOptions(QColorDialog.ShowAlphaChannel) ok = dialog.exec_() if ok: self.setColor(dialog.currentColor()) self.colorChanged.emit()
def onColorPick(self): dlg = QColorDialog(self) # if self._color: # dlg.setCurrentColor(QColor(self._color)) if dlg.exec_(): new_color = dlg.currentColor() self.setButtonColor(new_color) self.data_handle.set_color(new_color)
def setLabelColor(self): index = self.lstLabels.currentIndex() color = iconColor(self.mw.mdlLabels.item(index.row()).icon()) self.colorDialog = QColorDialog(color, self) color = self.colorDialog.getColor(color) if color.isValid(): px = QPixmap(32, 32) px.fill(color) self.mw.mdlLabels.item(index.row()).setIcon(QIcon(px)) self.updateLabelColor(index)
def set_color(self): if self.device: color = self.device.color().get("Color") if color: dlg = QColorDialog() new_color = dlg.getColor(QColor("#{}".format(color))) if new_color.isValid(): new_color = new_color.name() if new_color != color: self.mqtt.publish(self.device.cmnd_topic("color"), new_color)
def getColor(context, initial, title): if not isLinux: return QColorDialog.getColor(initial=initial, title=title) dlg = QColorDialog(initial, context) dlg.setWindowTitle(title) dlg.setOption(QColorDialog.DontUseNativeDialog) color = QColor() if dlg.exec() == QDialog.Accepted: color = dlg.currentColor() return color
def colorBtn_clicked(self): colorDialog = QColorDialog() colorDialog.setOption(QColorDialog.ShowAlphaChannel) color = colorDialog.getColor() if color.isValid(): self.frame.setStyleSheet(self.borderColor + ";" + 'background-color: %s' % color.name()) return
def set_upper_color(self): if self.tracker.detector is not self.color_detector: return dialog = QColorDialog() color = dialog.getColor( QColor(*self.tracker.detector.get_upper_color())) self.upperBoundColor.setStyleSheet("background-color: %s" % (color.name())) self.tracker.detector.set_upper_color(color.getRgb())
def __init__(self): super().__init__() self.main_window = self # 初始化颜色 self.color = QColor(107, 173, 246) # 创建颜色对话框--但不显示 self.color_dialog = QColorDialog(self.color, self.main_window) # 创建调色板 self.palette = QPalette()
def on_color_picker(self): ''' Show color-picker dialog to select color. Qt will use the native dialog by default. ''' dlg = QColorDialog(self) if self._color: dlg.setCurrentColor(QColor(self._color)) if dlg.exec_(): self.set_color(dlg.currentColor().name())
def getColorPolygonAndBrushStyle( initial_color: Union[QColor, Qt.GlobalColor, QGradient] = QColor(), initial_polygon: NodePolygon = NodePolygon.Circle, initial_brushstyle: Qt.BrushStyle = Qt.NoBrush, parent: Optional[QWidget] = None, title: str = '', options: Union[QColorDialog.ColorDialogOptions, QColorDialog.ColorDialogOption] = QColorDialog.ColorDialogOptions()) \ -> (QColor, NodePolygon): dlg = QColorDialog(parent) # Add buttons to select polygon polygons_group = QButtonGroup(parent) polygons_layout = QHBoxLayout(parent) for p in NodePolygon: if p == NodePolygon.Custom: continue button = QToolButton(parent) button.setCheckable(True) button.setText(p.name) button.setIcon(QIcon(nodePolygonToPixmap(p, button.iconSize()))) if p == initial_polygon: button.setChecked(True) polygons_group.addButton(button) polygons_group.setId(button, p.value) polygons_layout.addWidget(button) dlg.layout().insertLayout(dlg.layout().count()-1, polygons_layout) # Add buttons to select brush style brushstyle_group = QButtonGroup(parent) brushstyle_layout = QHBoxLayout(parent) for p in NODE_BRUSH_STYLES: button = QToolButton(parent) button.setCheckable(True) button.setIcon(QIcon(nodeBrushStyleToPixmap(p, button.iconSize()))) if p == initial_brushstyle: button.setChecked(True) brushstyle_group.addButton(button) brushstyle_group.setId(button, p) brushstyle_layout.addWidget(button) dlg.layout().insertLayout(dlg.layout().count()-1, brushstyle_layout) if title: dlg.setWindowTitle(title) dlg.setOptions(options) dlg.setCurrentColor(initial_color) dlg.exec_() return (dlg.selectedColor(), NodePolygon(polygons_group.checkedId()), brushstyle_group.checkedId(), )
def task_color_dialog(self): task_color = QColor(self.current_task_color) dialog = QColorDialog() if task_color is None: task_color = Qt.white dialog.setCustomColor(0, task_color) color = dialog.getColor() if color.isValid(): self.current_task_color = color.name() self.set_bg_color_to_widget(self.current_task_color, self.widgetColorTask)
def makeCentralContent(self): wg = QWidget() col = QColor(255, 255, 255) self.colordialog = QColorDialog() self.colorBox = QFrame() self.html_lbl = Label('HTML : ') linedit = QLineEdit() linedit.setReadOnly(True) linedit.setText(col.name()) linedit.mousePressEvent = lambda ev: clipboard.copy(linedit.text()) # self.colordialog.currentColorChanged.connect(self.on_changed_color) self.colordialog.currentColorChanged.connect( lambda: self.on_changed_color(self.colordialog, self.colorBox, linedit)) self.colordialog.setOption(QColorDialog.NoButtons) self.colordialog.setOption(QColorDialog.ShowAlphaChannel) #colordialog.setOption(QColorDialog.DontUseNativeDialog, False) self.colorBox.setStyleSheet('QWidget { background-color: %s }' % col.name()) self.colorBox.setGeometry(0, 0, 100, 100) hbox = QHBoxLayout() hbox.addWidget(self.colordialog) hbox_html = QHBoxLayout() hbox_html.addWidget(self.html_lbl) hbox_html.addWidget(linedit, 1) vbox_colorbox = QVBoxLayout() #vbox_colorbox.addStretch(1) vbox_colorbox.addWidget(self.colorBox, 1) # vbox_colorbox.addStretch(1) vbox_colorbox.addLayout(hbox_html, 1) vbox_colorbox.addStretch(2) hbox.addLayout(vbox_colorbox) vbox = QVBoxLayout() #vbox.addStretch(1) vbox.addLayout(hbox) vbox.addStretch(1) Info.MAIN_SCREEN_WIDTH += self.colordialog.width() Info.MAIN_SCREEN_WIDTH += self.colorBox.width() wg.setLayout(vbox) return wg
def choseCharacterColor(self): ID = self.currentCharacterID() c = self._model.getCharacterByID(ID) if c: color = iconColor(c.icon) else: color = Qt.white self.colorDialog = QColorDialog(color, mainWindow()) color = self.colorDialog.getColor(color) if color.isValid(): c.setColor(color) mainWindow().updateCharacterColor(ID)
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join(self.plugin_dir, 'i18n', 'Threshold3_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Declare instance attributes self.actions = [] self.menu = self.tr(u'&Threshold3') self.color_picker = QColorDialog() self.color_picker.setOption(QColorDialog.ShowAlphaChannel, on=True) self.t_0_COLOR = QColor(0, 0, 255) self.t_1_COLOR = QColor(0, 255, 0) self.t_2_COLOR = QColor(255, 0, 0) self.CLEAR = QColor(255, 255, 255, 0) self.layer = None self.fcn = None self.shader = None self.renderer = None self.is_initial = True self.MIN = float("inf") self.MAX = float("-inf") self.precision = 2 self.last_time = time() * 1000 self.render_debounce_timer = QTimer() self.render_debounce_timer.timeout.connect(self.render) self.render_debounce_timer.setSingleShot(True) # TODO: We are going to let the user set this up in a future iteration self.toolbar = self.iface.addToolBar(u'Threshold3') self.toolbar.setObjectName(u'Threshold3')
def ColorDialog_getColor(self, color=None, parent=None, name=None): from PyQt5.QtWidgets import QColorDialog from PyQt5.QtGui import QColor if color is None: color = QColor.black() if isinstance(color, str): color = QColor() cL = QColorDialog(color, parent) return cL.getColor()
def action_set_color_triggered(self): cd = QColorDialog(self.color) cd.exec_() this_color = cd.selectedColor() if this_color.isValid(): idx_GENOME = self.treeWidget().get_header_index(HEADER_GENOME) self.setBackground(idx_GENOME, this_color) self.color = this_color for i in range(0, self.childCount()): child = self.child(i) if child.plt is not None: child.plt.setPen(mkPen(color=self.color))
def _doubleClicked(self, index): model = self.model() if model is None: return data = model.data(index) if isinstance(data, QColor): dialog = QColorDialog(self) dialog.setCurrentColor(data) ret = dialog.exec_() if ret: color = dialog.currentColor() model.setData(index, color)
def _open_color_dialog(self): """opens a QColorDialog window to select color for PlotDataItem This function generates and open QColorDialog. Button signals are connected to functions which directly change color value of PlotDataItem """ self.restorable_color = self.data_item.get_color(rgb=False) self.color_dialog = QColorDialog() self.color_dialog.currentColorChanged.connect(self._set_color_from_dialog) self.color_dialog.rejected.connect(self._cancel_color_dialog) self.color_dialog.open()
def onColorPicker(self): ''' Show color-picker dialog to select color. Qt will use the native dialog by default. ''' dlg = QColorDialog() if self._color: dlg.setCurrentColor(self._color) if dlg.exec_(): self.setColor(dlg.selectedColor())
def open_colordialog(self, button): """ Open color dialog to get color for token Args: button: QPushButton """ color_dialog = QColorDialog() if color_dialog.exec_() == QColorDialog.Accepted: button.setStyleSheet("background-color: {}".format( color_dialog.selectedColor().name())) button.clearFocus() self.player_colors.append(color_dialog.selectedColor().name())
def on_colorblock_clicked(self): color = QColorDialog(self).getColor() button = self.groupBox_color.sender() m = re.match(r'(\w+)(\d+)', button.objectName()) target = int(m.group(2)) self.colorMap[target] = [color.red(), color.green(), color.blue()] self.colorblocks[target].setStyleSheet('QPushButton{background-color:%s}' % color.name()) for fij in self.f[target]: self.result[fij[0], fij[1]] = self.colorMap[target] misc.imsave('D:/temp2.png', self.result) self.label_IMG.setPixmap(QPixmap('D:/temp2.png')) self.label_progress.setText('完成!') os.remove('D:/temp2.png')
def mousePressEvent(self, event): scene_pos = self.mapToScene(event.pos()) pixmap = self.scene.itemAt(scene_pos) if not pixmap: return image = pixmap.pixmap().toImage() pos = int(scene_pos.x()), int(scene_pos.y()) if event.button() == Qt.LeftButton: dlg = QColorDialog() dlg.setCurrentColor(QColor(image.pixel(pos[0], pos[1]))) if dlg.exec_(): self.window.change_current_palette(pos, dlg.currentColor())
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # 初始化颜色 self.color = QColor(*settings.SKIN_COLOR) # 创建颜色对话框--但不显示 # self.color_dialog = QColorDialog(self.color, self.main_window) self.color_dialog = QColorDialog(self.color, self) # 创建调色板 self.palette = QPalette() self.options()
def edit_color(self): row = self.ui.colors.currentRow() column = self.ui.colors.currentColumn() old_color = self.ui.colors.currentItem().text() qcolor = QColorDialog().getColor(QColor("#" + old_color), self.dialog) if qcolor.isValid(): new_color = qcolor.name()[1:].lower() self.ui.colors.setItem(row, column, ColorItem(new_color)) self.directives = self.get_colors() self.populate() self.save()