Actually, assuming that the getattr() call *can* return a value in some 
circumstances, mumble mumble stylesheets, then presumably this is the fix?

                def weight_modifier(item: Item, param: str) -> None:
                    # attempt to turn eg 'Bold' into a stylesheet-derived 
value
                    arg = getattr(QtGui.QFont, param, None)
                    if arg is None:
                        # use our own mapping, eg. if no stylesheet in 
effect?
                        arg = {"Thin": QtGui.QFont.Weight.Thin,
                            "ExtraLight": QtGui.QFont.Weight.ExtraLight,
                            "Light": QtGui.QFont.Weight.Light,
                            "Normal": QtGui.QFont.Weight.Normal,
                            "Medium": QtGui.QFont.Weight.Medium,
                            "DemiBold": QtGui.QFont.Weight.DemiBold,
                            "Bold": QtGui.QFont.Weight.Bold,
                            "ExtraBold": QtGui.QFont.Weight.ExtraBold,
                            "Black": QtGui.QFont.Weight.Black
                            }.get(param, QtGui.QFont.Weight.Medium)
                    # apply the discovered weight
                    font = item.font(0)
                    font.setWeight(arg)
                    item.setFont(0, font)

                modifier = weight_modifier







On Thursday, October 31, 2024 at 10:47:38 PM UTC [email protected] wrote:

> On Thursday, October 31, 2024 at 6:22:20 PM UTC-4 jkn wrote:
>
> yes, that's nice to know, thanks for the tip. I got the values from the 
> PyQt documentation ... but I should have realised from the fact that 
> QFont.Weight is an Enum, that it would have names. Fancy new Python 
> features ... bring back v1.52, I say...
>
>
> Hear, Hear! 
>

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/leo-editor/e014d7a3-4773-4168-a293-eda8d6db8f41n%40googlegroups.com.

Reply via email to