UN-GCPDS / qt-material

Material inspired stylesheet for PySide2, PySide6, PyQt5 and PyQt6
https://qt-material.readthedocs.io/en/latest/
BSD 2-Clause "Simplified" License
2.39k stars 253 forks source link

QPalette' object has no attribute 'set_color' #86

Open YeongbinLim opened 1 year ago

YeongbinLim commented 1 year ago

`import sys from PyQt5.QtWidgets import QApplication, QWidget, QLabel from PyQt5.QtGui import QIcon from PyQt5.QtCore import pyqtSlot from qt_material import apply_stylesheet from qt_material import list_themes def MyApp(): app = QApplication(sys.argv) widget = QWidget()

textLabel = QLabel(widget) textLabel.setText("Hello World!") textLabel.move(150, 200)

widget.setGeometry(50, 50, 400, 400) widget.setWindowTitle("PyQt5 Example") list_themes() apply_stylesheet(app, theme='dark_teal.xml')

widget.show() sys.exit(app.exec_())

if name == 'main': app = QApplication(sys.argv) ex = MyApp() sys.exit(app.exec_())`

AttributeError: type object 'ColorRole' has no attribute 'Text'

During handling of the above exception, another exception occurred:

File "D:\study\pyqt\test.py", line 18, in MyApp apply_stylesheet(app, theme='dark_teal.xml') File "D:\study\pyqt\test.py", line 25, in ex = MyApp() AttributeError: 'QPalette' object has no attribute 'set_color'

version is qt-material 2.14 PyQt5 5.15.1

in init.py file I see u define pyqt5 as this code " try: print(dir(QPalette)) if hasattr( QPalette, 'PlaceholderText' ): # pyqt5, pyside2, pyside6 default_palette.setColor(QPalette.PlaceholderText, color) else: # pyqt6 default_palette.setColor(QPalette.ColorRole.Text, color) QGuiApplication.setPalette(default_palette) "

but there is no PlaceholderText in PyQt5/QtGui.pyi So we need to distinguish PyQt5 another way

YeongbinLim commented 1 year ago

image making it annotation worked with me