When I declare a variable in my CSS, my PySide2 application cannot parse it

53 Views Asked by At

When I declare an custom property (variable) in my CSS I get the following error when running the application:

Could not parse stylesheet of object Patrick(0x73e4780)

This is my code:

import sys, re

from module.widgets   import RuWidgets
from module.functions import *
from module.statics   import *

from PySide2.QtGui     import QFont, QFontDatabase, QIcon, QCursor
from PySide2.QtCore    import Qt, Signal, QThread, QPoint, QSettings
from PySide2.QtWidgets import QApplication, QMainWindow, QFrame, QMenu, QLineEdit, QWidget

class Patrick(QMainWindow):
    custom_colors = None

    def __init__(self):
        super().__init__()
        
        data = readJSON(CONFIGURATION, 'data')

        self.setWindowFlag(Qt.FramelessWindowHint)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setWindowTitle(NAME)
        self.setFixedSize(WIDTH, HEIGHT)
        self.setStyleSheet(
            """
            :root {
                --dark: #483939;
                --middle: #9C8181;
                --light: #D9D9D9;
            }

            #normal {
                background-color: var(--dark);
                color: var(--light);


            }

            #inverted {
                background-color: var(--light);
                color: var(--dark);

            }

            .full_rounded {
                border-radius: 8px, 8px, 8px, 8px;

            }

            .top_rounded {
                border-radius: 0px, 0px, 8px, 8px;

            }

            ::placeholder {
                color: var(--middle);
            }
            """
        )
        self.show()

        background = QFrame()
        background.setFixedSize(WIDTH, HEIGHT)
        bar = QFrame()
        bar.setFixedSize(WIDTH, WIDGET_HEIGHT)

        for widget, object_name, object_class in [
            (background, 'normal', 'full_rounded'),
            (bar, 'inverted', 'top_rounded')
        ]:
            widget.setObjectName(object_name)
            widget.setProperty(object_class, True)

        for widget in [
            background,
            bar

        ]:
            self.layout().addWidget(widget)

if __name__ == '__main__':
    application = QApplication(sys.argv)

    window = Patrick()
    
    #font = QFont(
    #    QFontDatabase.applicationFontFamilies(
    #        QFontDatabase.addApplicationFont(
    #            FONT.format('Inter-Regular')
    #        )
    #    )[0]
    #)
    #font.pointSize(FONT_SIZE)
    
    #application.setFont(font)
    application.exec_()

(DON'T READ: I'm sorry to have to write this here, but StackOverflow won't let me ask my question if I don't add more text regarding the amount of code I put in it, so I'm filling space, I hope there's no problem with that)

0

There are 0 best solutions below