本文整理汇总了Python中PyQt5.QtWidgets.QColorDialog类的典型用法代码示例。如果您正苦于以下问题:Python QColorDialog类的具体用法?Python QColorDialog怎么用?Python QColorDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QColorDialog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: change_preview_background
def change_preview_background(self):
qcolor = QColorDialog().getColor(QColor(self.preview_bg),
self.window)
if qcolor.isValid():
self.preview_bg = qcolor.name()
self.update_player_preview()
示例2: on_bTest_clicked
def on_bTest_clicked(self):
"""
Private method to test the selected options.
"""
if self.rColor.isChecked():
if not self.eColor.currentText():
QColorDialog.getColor()
else:
coStr = self.eColor.currentText()
if coStr.startswith("#"):
coStr = "QColor('{0}')".format(coStr)
else:
coStr = "QColor({0})".format(coStr)
try:
exec(
"from PyQt5.QtCore import Qt;"
' QColorDialog.getColor({0}, None, "{1}")'.format(coStr, self.eTitle.text())
)
except:
E5MessageBox.critical(
self,
self.tr("QColorDialog Wizard Error"),
self.tr("""<p>The colour <b>{0}</b> is not valid.</p>""").format(coStr),
)
elif self.rRGBA.isChecked():
QColorDialog.getColor(
QColor(self.sRed.value(), self.sGreen.value(), self.sBlue.value(), self.sAlpha.value()),
None,
self.eTitle.text(),
QColorDialog.ColorDialogOptions(QColorDialog.ShowAlphaChannel),
)
示例3: changeColor
def changeColor(self):
# try:
if self.sender() == self.colormode.ui.comboBoxFGColor:
color_str = self.colormode.ui.comboBoxFGColor.currentText()
if color_str == 'CUSTOM':
color = _QColorDialog.getColor().getRgb()
color = [round(color[0]/255,2), round(color[1]/255,2), round(color[2]/255,2)]
self.data.colormap = color
else:
self.data.colormap = _mpl.colors.colorConverter.to_rgb(_mpl.colors.cnames[color_str])
elif self.sender() == self.colormode.ui.comboBoxBGColor:
bgcolor_str = self.colormode.ui.comboBoxBGColor.currentText()
if bgcolor_str == 'CUSTOM':
bgcolor = _QColorDialog.getColor().getRgb()
bgcolor = [round(bgcolor[0]/255,2), round(bgcolor[1]/255,2), round(bgcolor[2]/255,2)]
self.data.bgcolor = bgcolor
else:
self.data.bgcolor = _mpl.colors.colorConverter.to_rgb(_mpl.colors.cnames[bgcolor_str])
self.createImg(img = self.data.image, xunits = self.data.xunits,
yunits = self.data.yunits,
extent = self.data.winextent)
self.mpl.draw()
示例4: tableWidgetCellDoubleClicked
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()
示例5: _show_color_dialog
def _show_color_dialog(current_color, parent):
dialog = QColorDialog()
for idx, color in enumerate(DEFAULT_COLORS):
dialog.setCustomColor(idx, color)
current_color = dialog.getColor(current_color, parent, 'Select line color')
if current_color.isValid():
return current_color
示例6: edit_color
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))
示例7: pickColor
def pickColor(self):
if self._readOnly:
return
dialog = QColorDialog(self._color)
dialog.setOptions(QColorDialog.ShowAlphaChannel)
ok = dialog.exec_()
if ok:
self.setColor(dialog.currentColor())
self.colorChanged.emit()
示例8: mouseDoubleClickEvent
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()
示例9: mouseDoubleClickEvent
def mouseDoubleClickEvent(self, event):
event.accept()
if self._readOnly:
return
dialog = QColorDialog()
ok = dialog.exec_()
if ok:
self.setColor(dialog.currentColor())
self.colorChanged.emit()
示例10: ColorDialog_getColor
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()
示例11: showDialog
def showDialog(self):
col = QColorDialog.getColor()
if col.isValid():
self.frm.setStyleSheet("QWidget { background-color: %s }"
% col.name())
示例12: chooseBestColor
def chooseBestColor(self):
self.bestColor = QColorDialog.getColor(self.bestColor)
self.setBestColorButton(self.bestColor)
if self.tag != None:
self.taggedTextWidget.showDataNoWait(self.tag)
self.taggedDocumentWidget.showDateNoWaitDetails(self.tag)
self.update_colorbar()
示例13: _bbTableDoubleClicked
def _bbTableDoubleClicked(self, row, col):
"""
This overrides the callback for table's double click
set in the CustomWidget object.
Apparently if there is an exception it falls back to
the original callback... Not sure why this behaviour.
NOTE: This is kind of nasty.
:return: None
"""
it = self.table.item(row, col).text()
try:
idx = int(it) # decimal
bb_path = self.ba.cache.bb_paths[idx]
col = QColorDialog.getColor()
if col.isValid():
# IDA works with BGR (annoying)
ida_color = misc.pyside_to_ida_color(col.name())
misc.paint_basic_blocks(bb_path, ida_color)
else:
print '[x] Invalid QColor'
return
except IndexError:
# Address value (does not contain [A-F]) is interpreted as index
return
except ValueError:
# Address value (containing [A-F]) fucks up int()
return
示例14: on_bgcolor_click
def on_bgcolor_click(self):
initial = self.input_bgcolor.text()
color = QColorDialog.getColor(QColor(initial), self, "Choose background color")
if color.isValid():
self.input_bgcolor.setText(color.name())
self.update_colors(fg_override=self.input_fgcolor.text(), bg_override=color.name())
示例15: bgColorDialog
def bgColorDialog(self):
"""Open color dialog to pick a color.
"""
color = QColorDialog.getColor()
if color.isValid():
self.bgColor = color
common.setPickerColor(color, self.bgColorPicker)