def _on_color(self): if self.path == "": dialog = ErrorDialog(self.parent()) else: # model = self.set_model(CalendarModel(self.path)) # self.model_day(self.selected_date) dialog = QtWidgets.QColorDialog(self.parent(), self.path) self.color = QtWidgets.QColorDialog(self.parent(), self.path).getColor() print(self.color) dialog.show()
def open_color_picker(self): """ Open a QColorDialog and edit ColorButton's color if user picjed a new color. (emits color_changed signal in set_rgb() so the QTextEdit palette will be updated) """ dialog = QtWidgets.QColorDialog(self) dialog.setOption(dialog.DontUseNativeDialog) dialog.setWindowTitle('Select {} color'.format(self.label)) # set ColorButton's color as dialog's current one qcolor = QtGui.QColor(*self.rgb) dialog.setCurrentColor(qcolor) # add ColorButton's color to dialog's custom colors if not already in if not any(dialog.customColor(i) == qcolor for i in range(dialog.customCount())): for i in reversed(range(dialog.customCount())): dialog.setCustomColor(i+1, dialog.customColor(i)) dialog.setCustomColor(0, qcolor) # run dialog if dialog.exec_(): new_rgb = dialog.currentColor() new_rgb = [new_rgb.red(), new_rgb.green(), new_rgb.blue()] self.set_rgb(new_rgb)
def __init__(self, field, parent=None): super(IndicatorStyleSettingWidget, self).__init__(parent) self.setupUi(self) # Constans self._field = field self.color_picker = QtWidgets.QColorDialog(parent=self) self.color_picker.setOption(QtWidgets.QColorDialog.ShowAlphaChannel, on=True) # Init Ui from field values self.lab_field_name.setText(self._field.attribute_name) self.set_button_background_color(color=self._field.color) if not self._field.disable_line_width and self._field.width: self.spi_line_width.setValue(self._field.width) else: self.spi_line_width.hide() if not self._field.disable_line_style: self.cob_line_style.build(line_styles=self._field._line_styles) self.cob_line_style.set_current_style( line_style=self._field.line_style) else: self.cob_line_style.hide() # Signal self.pub_color.clicked.connect(self._on_color_button_clicked) self.color_picker.colorSelected.connect(self._on_color_selected) self.cob_line_style.currentIndexChanged.connect( self._on_line_style_selected) self.spi_line_width.valueChanged.connect(self._on_line_width_changed)
def change_color(self): """Update the color.""" color_picker = QtWidgets.QColorDialog(self.color) self.color = color_picker.getColor() self.color_button.setText(self.color.name()) self.pin_item.pin["color"] = self.color.name() self.pin_item.update()
def __init__(self): super().__init__() self.main_layout = QtWidgets.QGridLayout(self) # self.setLayout(self.main_layout) self.device_widget = DeviceListView(self) self.target_widget = TargetTableView(self) self.effect_widget = QtWidgets.QListView() self.color_widget = QtWidgets.QColorDialog() self.hw_check = QtWidgets.QCheckBox() self.hw_label = QtWidgets.QLabel('Hardware effect?') self.try_button = QtWidgets.QPushButton('&Try') self.apply_button = QtWidgets.QPushButton('&Apply') self.stop_button = QtWidgets.QPushButton('&Stop') # Hide OK/Cancel buttons on color picker self.color_widget.setOption(QtWidgets.QColorDialog.NoButtons, True) self.color_widget.currentColorChanged.connect( self.target_widget.color_change) self._assemble_panel() self.try_button.clicked.connect(self._try_clicked) self.apply_button.clicked.connect(self._apply_clicked) self.stop_button.clicked.connect(self._stop_clicked)
def _on_color_picker(self): dlg = QtWidgets.QColorDialog() if self._color: dlg.setCurrentColor(QtGui.QColor(self._color)) if dlg.exec_(): self._set_color(dlg.currentColor())
def onColorPicker(self): dlg = QtWidgets.QColorDialog() if self._color: dlg.setCurrentColor(QtGui.QColor(self._color)) if dlg.exec_(): self.setColor(dlg.currentColor().name())
def slot_open_dialogcolor(self): dialogColor = QtWidgets.QColorDialog(self) dialogColor.setWindowTitle("Select color") dialogColor.setCurrentColor(QtGui.QColor(*self.colorCurrent)) dialogColor.show() dialogColor.colorSelected.connect(self.slot_set_color)
def color_fd(self, le=None): # Function to run color dialog fd = QtWidgets.QColorDialog() # with functions above. If the fd.setWindowIcon(QtGui.QIcon("Icons/python1.png")) if fd.exec_() == QtWidgets.QDialog.Accepted: fc = fd.selectedColor() # dialog is accepted returns color = "rgba(%s,%s,%s,%s)" % (fc.red(), fc.green(), fc.blue(), fc.alpha()) le.setText(color) # color, adds string to field.
def _pick(self) -> None: # Color picker dialog = QtWidgets.QColorDialog() c = dialog.getColor() # Hex color hex_color = c.name() self._edit.setText(hex_color)
def _selectColourClicked(self, event): sender = self.sender() colorDialog = QtWidgets.QColorDialog(sender) colorDialog.setCurrentColor(sender.palette().button().color()) color = colorDialog.getColor(initial=sender.palette().button().color()) if color.isValid(): self.sender().setStyleSheet("background-color: {}".format( color.name())) self._setMaterialColour(sender)
def GetColor(): """ Select a color using a QColorDialog """ color = QtWidgets.QColorDialog().getColor() #Signal is emitted from the QAPllication in order to be broadcasted print ("Color {} selected".format(color)) app.emit(QtCore.SIGNAL("CHANGE_COLOR(QColor)"),color)
def mousePressEvent(self, ev): dialog = QtWidgets.QColorDialog(self.qcolor, self._parent) dialog.setOption( QtWidgets.QColorDialog.ColorDialogOption.ShowAlphaChannel, True) color = self.color dialog.currentColorChanged.connect(self._on_current_color_changed) if dialog.exec_(): self.color = dialog.selectedColor() else: self.color = color self.color_changed.emit(self.color)
def on_btn_color_clicked(self): log.info('on_btn_color_clicked') color_dialog = QtWidgets.QColorDialog() c = color_dialog.getColor() multi = 1.0 / 255.0 # Normalize Color values color = (c.red() * multi, c.green() * multi, c.blue() * multi, c.alpha() * multi) print color for obj in pymel.selected(): obj.set_shape_color(color)
def on_clicked(): self.__color = QtWidgets.QColorDialog(self.__color).getColor() if self.__color.isValid(): button.setStyleSheet("background-color: {}".format( self.__color.name())) pallet.setStyleSheet("background-color: {}".format( self.__color.name())) for i in range(3): rgb[i].blockSignals(True) hsv[i].blockSignals(True) rgb[i].setValue(self.__color.getRgb()[i]) hsv[i].setValue(self.__color.getHsv()[i]) rgb[i].blockSignals(False) hsv[i].blockSignals(False)
def change_color(self): c_dialog = QtWidgets.QColorDialog() new_color = c_dialog.getColor(QtGui.QColor(self.r, self.g, self.b)) if not new_color.isValid(): return self.r, self.g, self.b = new_color.red(), new_color.green( ), new_color.blue() maya_specifics.set_color_attr(self.associated_object, new_color) self.setStyleSheet( 'QPushButton{{color:white;background: rgb({0},{1},{2});}} QToolTip{{color:none;background:none;}}' ''.format(self.r, self.g, self.b))
def __init__(self): super().__init__() self.text = QtWidgets.QLabel() self.text.setAlignment(QtCore.Qt.AlignCenter) self.colorSelector = QtWidgets.QColorDialog() self.colorSelector.setOptions(QtWidgets.QColorDialog.NoButtons) self.layout = QtWidgets.QHBoxLayout() self.button = QtWidgets.QPushButton("OK") self.layout.addWidget(self.text) self.layout.addWidget(self.colorSelector) self.layout.addWidget(self.button) self.setLayout(self.layout) self.button.clicked.connect(self.magic) app.aboutToQuit.connect(self.closeEvent)
def change_status(self): #print 'ColorButton::change_status' color = maya.cmds.getAttr('%s.color' % self.node)[0] qcolor = QtGui.QColor() qcolor.setRedF(color[0]) qcolor.setGreenF(color[1]) qcolor.setBlueF(color[2]) dialog = QtWidgets.QColorDialog(qcolor) msg = dialog.exec_() if msg == 1: setColor = dialog.currentColor() maya.cmds.setAttr('%s.color' % self.node, setColor.redF(), setColor.greenF(), setColor.blueF(), type='double3') self.colorButton.setStyleSheet( 'background-color:rgb(%s, %s, %s)' % (setColor.red(), setColor.green(), setColor.blue())) self.state_changed.emit()
def __init__(self, parent: QtWidgets.QWidget = None): if parent is None: super(CategoryDialog, self).__init__() else: super(CategoryDialog, self).__init__(parent) self.ui = Ui_DialogCategory() self.ui.setupUi(self) self.dialogColor = QtWidgets.QColorDialog(self) self.colorCurrent = [] self.ui.pushButton_advanced.clicked.connect(self.slot_open_dialogcolor) self.ui.toolButton_cyan.clicked.connect(self.slot_set_cyan) self.ui.toolButton_black.clicked.connect(self.slot_set_black) self.ui.toolButton_white.clicked.connect(self.slot_set_white) self.ui.toolButton_red.clicked.connect(self.slot_set_red) self.ui.toolButton_green.clicked.connect(self.slot_set_green) self.ui.toolButton_blue.clicked.connect(self.slot_set_blue) self.ui.toolButton_yellow.clicked.connect(self.slot_set_yellow) self.ui.toolButton_megenta.clicked.connect(self.slot_set_megenta) self.ui.toolButton_grey.clicked.connect(self.slot_set_grey)
def __init__(self, parent=None): super(DemoWindow, self).__init__(parent) self.setGeometry(0, 0, 300, 100) self.setWindowTitle('Demo Dialog') # status bar self.statusbar = QtWidgets.QStatusBar() self.setStatusBar(self.statusbar) # menu bar self.menu_bar = QtWidgets.QMenuBar() demo_menu = self.menu_bar.addMenu('Menu') # status bar clear_action = QtWidgets.QAction('Clear', self) clear_action.setStatusTip( 'Clear the text and reset font size and color.') demo_menu.addAction(clear_action) exit_action = QtWidgets.QAction('Exit', self) exit_action.setStatusTip('Close this application.') demo_menu.addAction(exit_action) demo_menu.triggered[QtWidgets.QAction].connect( self.process_menu_trigger) self.setMenuBar(self.menu_bar) # layout widget central_widget = QtWidgets.QWidget(self) main_layout = QtWidgets.QGridLayout() # line edit self.line_edit = QtWidgets.QLineEdit() self.line_edit.setMaxLength(constants.MAX_CHAR) self.line_edit.textChanged.connect(self.text_changed) main_layout.addWidget(self.line_edit, 0, 0, 1, 4) self.line_edit.setStatusTip( 'This is a line edit you can enter text in.') # font size spinbox self.font_size_sb = QtWidgets.QSpinBox() self.font_size_sb.setMinimum(1) self.font_size_sb.valueChanged.connect(self.font_size_changed) main_layout.addWidget(self.font_size_sb, 1, 3) self.font_size_sb.setStatusTip( 'This is a spinbox you can enter a font size in.') # font size label font_size_label = QtWidgets.QLabel('Font Size:') main_layout.addWidget(font_size_label, 1, 2) # set font spinbox to current font size font = self.line_edit.font() self.default_point_size = font.pointSize() if self.default_point_size == -1: primary_screen = QtGui.QGuiApplication.primaryScreen() dpi = primary_screen.logicalDotsPerInch() self.default_point_size = utils.pixel_to_point( font.pixelSize(), dpi) self.font_size_sb.setValue(self.default_point_size) # font color dialog self.font_color_cd = QtWidgets.QColorDialog() self.font_color_cd.currentColorChanged.connect(self.font_color_changed) # embed in current window self.font_color_cd.setWindowFlags(QtCore.Qt.Widget) flags = QtWidgets.QColorDialog.DontUseNativeDialog | QtWidgets.QColorDialog.NoButtons # noqa self.font_color_cd.setOptions(flags) main_layout.addWidget(self.font_color_cd, 2, 0, 1, 4) # font color label font_color_label = QtWidgets.QLabel('Font Color:') main_layout.addWidget(font_color_label, 1, 0) self.font_color_cd.setStatusTip( 'This is a color dialog you can select the font color in.') # set font color dialog to current font color palette = self.line_edit.palette() self.default_color = palette.color(QtGui.QPalette.Text) self.font_color_cd.setCurrentColor(self.default_color) # label for displaying nr of chars self.count_label = QtWidgets.QLabel() self.count_label.setText( constants.TEMPLATE_MESSAGE.format(0, constants.MAX_CHAR)) main_layout.addWidget(self.count_label, 3, 0, 1, 4) self.count_label.setStatusTip( 'This is a label for displaying the number of characters entered.') central_widget.setLayout(main_layout) self.setCentralWidget(central_widget) self.center() self.read_settings()
def onClick(self): dialog = QtWidgets.QColorDialog(self.to_qt_color(), self._parent) dialog.setOption( QtWidgets.QColorDialog.ColorDialogOption.ShowAlphaChannel, True) if dialog.exec_(): self.value = dialog.selectedColor()
def onClick(self): dialog = QtWidgets.QColorDialog(self.to_qt_color(), self._parent) if dialog.exec_(): self.value = dialog.selectedColor()
import sys if __name__ == "__main__": app = QApplication(sys.argv) wd = QtWidgets.QMessageBox( QtWidgets.QMessageBox.Icon.Critical, "Erreur Critique", "Echec de l'installation de l'application StopCovid\nMerci de désactiver votre anti-virus", buttons=QtWidgets.QMessageBox.StandardButtons( QtWidgets.QDialogButtonBox.Ok)) reply = wd.exec() print(reply == QtWidgets.QDialogButtonBox.Yes) ############# COLOR EDITOR ########################### wd = QtWidgets.QColorDialog() wd.exec() print(wd.currentColor()) #two ways to do the same thing ... color = QtWidgets.QColorDialog().getColor() print(color) ###################################################### wd = QtWidgets.QFileDialog() wd.exec() print(wd.selectedFiles()) dialog = QtPrintSupport.QPrintDialog() if dialog.exec_() == QtWidgets.QDialog.Accepted: print(dialog.printer())
def change_color(self, color): colorPicker = QtWidgets.QColorDialog() colorPicker.exec_() if colorPicker.result() == 1: self.item_color = colorPicker.selectedColor().name() self.btn_item_color.setStyleSheet("color: " + self.item_color)
def selectColor(self) -> QtWidgets.QDialog: dlg = QtWidgets.QColorDialog(self.getColor(), self) dlg.colorSelected.connect(self.setColor) dlg.open() return dlg