Open Anandir opened 3 years ago
Look at the Palette class and create your own subclass. Do take some inspiration from light palette or dark palette. You might also need the color system.
Then use the palette class (not instance) as arguement when loading the style sheet. Example here with LightPalette
import sys
import qdarkstyle
from qdarkstyle.light.palette import LightPalette
from PyQt6.QtWidgets import QWidget, QMainWindow, QApplication, QPushButton, QLineEdit, QLabel, QVBoxLayout
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
# Set window title and size
self.setWindowTitle("Example PyQt6 App")
self.setGeometry(100, 100, 400, 300)
# Create central widget and set layout
central_widget = QWidget()
layout = QVBoxLayout()
# Add a button
button = QPushButton("Click Me")
layout.addWidget(button)
# Add a text input field
input_field = QLineEdit()
input_field.setPlaceholderText("Enter something here...")
layout.addWidget(input_field)
# Add a label for random stuff
label = QLabel("Random Label")
layout.addWidget(label)
# Add some more random stuff (another button)
another_button = QPushButton("Another Button")
layout.addWidget(another_button)
# Set the layout to the central widget
central_widget.setLayout(layout)
self.setCentralWidget(central_widget)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
# Apply the darkstyle theme using a light palette
window.setStyleSheet(qdarkstyle.load_stylesheet(
palette=LightPalette
))
window.show()
sys.exit(app.exec())
I've only tested using the light palette. Could you report back if creating a subclass works?
Hi everyone. First of all, thanks for your hard work. I've tried, with no luck, to create a custom color palette for an application I'm going to develop. How can I create a custom palette of colors and, subsequently, the .qss file for the application? I've looked at the Python code, but I didn't really spot a way to do so.
Even if the snippet on the scss.py file worked. And I don't really understand what I'm doing wrong.
Do you have any ideas?
Best regards Giacomo