本文整理匯總了Python中PyQt5.QtWidgets.QColorDialog方法的典型用法代碼示例。如果您正苦於以下問題:Python QtWidgets.QColorDialog方法的具體用法?Python QtWidgets.QColorDialog怎麽用?Python QtWidgets.QColorDialog使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QColorDialog方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _init_colorpicker
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QColorDialog [as 別名]
def _init_colorpicker(self):
colorpicker = QtWidgets.QColorDialog()
colorpicker.finished.connect(self.colorpicker_finished)
return colorpicker
示例2: get_color
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QColorDialog [as 別名]
def get_color(self, current_color):
color_dialog = QtWidgets.QColorDialog()
new_color = color_dialog.getColor(current_color)
if new_color.isValid(): # Returned in case cancel is pressed
return new_color
else:
return current_color
示例3: changeLabelColor
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QColorDialog [as 別名]
def changeLabelColor(self):
if self.currentwidget is None:
return
if isinstance(self.currentwidget, displaymod.labelWidget):
colordialog = widgets.QColorDialog()
color = colordialog.getColor()
if color.isValid():
self.currentwidget.jsondata['color'] = "rgb(%i,%i,%i)" % (color.red(), color.green(), color.blue())
self.reinitScreen()
示例4: __init__
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QColorDialog [as 別名]
def __init__(self, *args, **kwargs):
QtWidgets.QDialog.__init__(self, *args, **kwargs)
self.completer = QtWidgets.QCompleter()
self.completer_model = QtWidgets.QFileSystemModel(self.completer)
self.completer.setModel(self.completer_model)
self.completer.setMaxVisibleItems(8)
loadUi(get_resource('dialog_config.ui'), self)
self.ok_button.released.connect(
self.setAttributes)
self.ok_button.released.connect(
self.close)
self.apply_button.released.connect(
self.setAttributes)
self.vector_color_picker = QtWidgets.QColorDialog(self)
self.vector_color_picker. \
setCurrentColor(QtGui.QColor(*getConfig().vector_color))
self.vector_color_picker. \
setOption(self.vector_color_picker.ShowAlphaChannel)
self.vector_color_picker.colorSelected.connect(
self.updateVectorColor)
self.vector_color_picker.setModal(True)
self.vector_color.clicked.connect(
self.vector_color_picker.show)
self.vector_color.setValue = self.setButtonColor
self.vector_color.value = self.getButtonColor
self.chooseStoreDirButton.released.connect(
self.chooseStoreDir)
self.completer_model.setRootPath('')
self.completer.setParent(self.default_gf_dir)
self.default_gf_dir.setCompleter(self.completer)
self.getAttributes()
示例5: onColorPicker
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QColorDialog [as 別名]
def onColorPicker(self):
dlg = QColorDialog()
if self._color is not None:
dlg.setCurrentColor(QColor(self._color))
if dlg.exec_() == dlg.Accepted:
self.setColor(dlg.currentColor().name())
示例6: ask_color
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QColorDialog [as 別名]
def ask_color(initial=None):
if initial is not None:
color = QtGui.QColor(initial & 0xFF, (initial >> 8) & 0xFF, (initial >> 16) & 0xFF)
qcolor_dialog = QtWidgets.QColorDialog(color)
else:
qcolor_dialog = QtWidgets.QColorDialog()
qcolor = qcolor_dialog.getColor()
if not qcolor.isValid:
return None
return (qcolor.blue() << 16) | (qcolor.green() << 8) | (qcolor.red() << 0)
示例7: ColorButtonClicked
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QColorDialog [as 別名]
def ColorButtonClicked(self):
"""Show the QColorDialog to let user choose new color"""
dlg = QtWidgets.QColorDialog(self.color, self)
if self.isAlpha:
dlg.setOption(QtWidgets.QColorDialog.ShowAlphaChannel)
if dlg.exec_():
self.setColor(dlg.currentColor())
self.valueChanged.emit(dlg.currentColor().name())
示例8: colorButtonClicked
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QColorDialog [as 別名]
def colorButtonClicked(self):
"""Show QColorDialog to change the color"""
dlg = QtWidgets.QColorDialog(self.color, self)
if dlg.exec_():
self.setColor(dlg.currentColor())
示例9: colordialog
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QColorDialog [as 別名]
def colordialog(self):
"""Show dialog to choose font color"""
dialog = QtWidgets.QColorDialog(self.notas.textColor(), self)
if dialog.exec_():
self.FontColor.setPalette(QtGui.QPalette(dialog.currentColor()))
self.notas.setTextColor(dialog.currentColor())
format = QtGui.QTextCharFormat()
format.setForeground(dialog.currentColor())
self.MergeFormat(format)
示例10: __init__
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QColorDialog [as 別名]
def __init__(self):
super().__init__()
self.tcl = ThreeColorLed(8, 10, 12)
ccd = qtw.QColorDialog()
ccd.setOptions(
qtw.QColorDialog.NoButtons
| qtw.QColorDialog.DontUseNativeDialog)
ccd.currentColorChanged.connect(self.set_color)
self.setCentralWidget(ccd)
self.show()
開發者ID:PacktPublishing,項目名稱:Mastering-GUI-Programming-with-Python,代碼行數:14,代碼來源:three_color_led_gui.py
示例11: get_color
# 需要導入模塊: from PyQt5 import QtWidgets [as 別名]
# 或者: from PyQt5.QtWidgets import QColorDialog [as 別名]
def get_color(self, signal_sender):
def open_color_dialog(current_color):
color_dialog = QtWidgets.QColorDialog()
new_color = color_dialog.getColor(current_color)
if new_color.isValid(): # Returned in case cancel is pressed
return new_color
else:
return current_color
# Special cases that don't affect (comic)book display
if signal_sender == 'libraryBackground':
current_color = self.settings['listview_background']
new_color = open_color_dialog(current_color)
self.listView.setStyleSheet("QListView {{background-color: {0}}}".format(
new_color.name()))
self.settings['listview_background'] = new_color
return
if signal_sender == 'dialogBackground':
current_color = self.settings['dialog_background']
new_color = open_color_dialog(current_color)
self.settings['dialog_background'] = new_color
return
profile_index = self.bookToolBar.profileBox.currentIndex()
current_profile = self.bookToolBar.profileBox.itemData(
profile_index, QtCore.Qt.UserRole)
# Retain current values on opening a new dialog
if signal_sender == 'fgColor':
current_color = current_profile['foreground']
new_color = open_color_dialog(current_color)
self.bookToolBar.colorBoxFG.setStyleSheet(
'background-color: %s' % new_color.name())
current_profile['foreground'] = new_color
elif signal_sender == 'bgColor':
current_color = current_profile['background']
new_color = open_color_dialog(current_color)
self.bookToolBar.colorBoxBG.setStyleSheet(
'background-color: %s' % new_color.name())
current_profile['background'] = new_color
elif signal_sender == 'comicBGColor':
current_color = self.comic_profile['background']
new_color = open_color_dialog(current_color)
self.bookToolBar.comicBGColor.setStyleSheet(
'background-color: %s' % new_color.name())
self.comic_profile['background'] = new_color
self.bookToolBar.profileBox.setItemData(
profile_index, current_profile, QtCore.Qt.UserRole)
self.format_contentView()