Could not parse stylesheet of object QLabel(0x1abb30d3130, name = "label_6")

Maurizio Berti maurizio.berti at gmail.com
Thu Oct 24 02:10:47 BST 2024


I don't really know why you get different error results with this:

".QLabel#label_6 {background-color: rgb(0, 0, 0)};"

As there shouldn't be any difference with it, no matter if run from a
pyinstaller or not. Maybe you just run the code from the IDE, and its
debugger doesn't show stderr messages from the module (in that case,
remember that it's *always* good practice to test code outside of the IDE,
in a terminal or prompt).

In any case, the syntax is wrong to begin with: semicolons are only
accepted as rule separators within selector definitions or, eventually when
no selector exists at all.
Which is fundamentally identical to the original CSS syntax specification,
on which QSS are based.

Besides, if you are actually setting the style sheet on the label, it has
no children, and no other selectors are required (eg. for hovering or
different widget states), there's really no point in using the
.Class#objectName selector to begin with. Either use the generic QLabel
selector for code compliance, or don't use a selector to begin with.

Regards

Il giorno mer 23 ott 2024 alle ore 18:21 Luca Bertolotti <
luca72.bertolotti at gmail.com> ha scritto:

> Sorry I make a mistake when i copy the line
> In pyqt I never get any error with this line
> self.label_6.setStyleSheet(".QLabel#label_6 {background-color: rgb(0, 0,
> 0)};")
> but with pyinstaller yes
> but I solve it in this way
> self.label_6.setStyleSheet(".QLabel#label_6 {background-color: rgb(0, 0,
> 0);}")
> Regards
>
> Il giorno mer 23 ott 2024 alle ore 13:43 Florian Bruhin <
> me at the-compiler.org> ha scritto:
>
>> On 2024-10-23T13:08:19 , Luca Bertolotti wrote:
>> > self.label_6.setStyleSheet(".QLabel#label_6 {background-color: rgb(0,
>> 0, 0};")
>>
>> You are missing a closing ) for rgb(...).
>>
>> None of this is related to PyInstaller (or PyQt for that matter),
>> it should fail jn the exact same way if you just run your code.
>>
>> Florian
>>
>

-- 
È difficile avere una convinzione precisa quando si parla delle ragioni del
cuore. - "Sostiene Pereira", Antonio Tabucchi
http://www.jidesk.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20241024/c31ef148/attachment.htm>


More information about the PyQt mailing list