mirror of
https://github.com/pyapp-kit/superqt.git
synced 2025-12-15 18:50:05 +01:00
* feat: add QColorCombo * more features * test: add some tests * fix: import the future * more tests * style: [pre-commit.ci] auto fixes [...] --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
24 lines
646 B
Python
24 lines
646 B
Python
from qtpy.QtGui import QColor
|
|
from qtpy.QtWidgets import QApplication
|
|
|
|
from superqt import QColorComboBox
|
|
|
|
app = QApplication([])
|
|
w = QColorComboBox()
|
|
# adds an item "Add Color" that opens a QColorDialog when clicked
|
|
w.setUserColorsAllowed(True)
|
|
|
|
# colors can be any argument that can be passed to QColor
|
|
# (tuples and lists will be expanded to QColor(*color)
|
|
COLORS = [QColor("red"), "orange", (255, 255, 0), "green", "#00F", "indigo", "violet"]
|
|
w.addColors(COLORS)
|
|
|
|
# as with addColors, colors will be cast to QColor when using setColors
|
|
w.setCurrentColor("indigo")
|
|
|
|
w.resize(200, 50)
|
|
w.show()
|
|
|
|
w.currentColorChanged.connect(print)
|
|
app.exec_()
|