initial commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
from PyQt6.QtWidgets import QWidget, QHBoxLayout, QPushButton
|
||||
from PyQt6.QtCore import Qt
|
||||
from palette import PALETTE
|
||||
|
||||
class ColorSwatchPopup(QWidget):
|
||||
def __init__(self, callback, parent=None):
|
||||
super().__init__(parent, Qt.WindowType.Popup)
|
||||
self.callback = callback
|
||||
layout = QHBoxLayout(self)
|
||||
layout.setContentsMargins(4, 4, 4, 4)
|
||||
layout.setSpacing(4)
|
||||
for name, hex_color in PALETTE:
|
||||
btn = QPushButton()
|
||||
btn.setFixedSize(22, 22)
|
||||
btn.setStyleSheet(f"""
|
||||
QPushButton {{
|
||||
background-color: {hex_color};
|
||||
border-radius: 3px;
|
||||
border: 1px solid rgba(255,255,255,0.2);
|
||||
}}
|
||||
QPushButton:hover {{
|
||||
border: 2px solid #00ff88;
|
||||
}}
|
||||
""")
|
||||
btn.clicked.connect(lambda checked, n=name, c=hex_color: self.pick(n, c))
|
||||
layout.addWidget(btn)
|
||||
self.setStyleSheet("background-color: #2d2d2d; border-radius: 4px;")
|
||||
|
||||
def pick(self, name, hex_color):
|
||||
self.callback(name, hex_color)
|
||||
self.close()
|
||||
Reference in New Issue
Block a user