I don't see how it can work because any string that goes along with WEIGHT 
that feed into the function gets discarded, and then you get the default.  
But as I said, it's hard to work through to be sure. "75" would give a 
light to normal weight, depending on the font. 

On Thursday, October 31, 2024 at 10:47:34 AM UTC-4 jkn wrote:

> Yes, this matches my (brief) investigations.
>
> But using
>
> WEIGHT 700
>
> did not work either - I had to use 700 as the default in the getattr() 
> call, as I wrote a few posts above.
>
> i am suspecting that the original code didn't properly work in PyQt5, and 
> any WEIGHT line would cause the default in the getattr() to be returned. 
> That used to be 75, but has to be er. 700 for bold in PyQt6.
>
> I will try whether WEIGHT 100 does anything (eg. feint, the opposite of 
> bold) in PyQt5.  suspect not ... in which case there is a small bug here, I 
> think. I will attempt to fix it.
>
> On Thursday, October 31, 2024 at 2:24:38 PM UTC [email protected] wrote:
>
>> I had a quick look at the way it's used, and I find it hard to 
>> understand.  I can see the intention but the layers of indirection make it 
>> hard. Say the pattern in myLeoSettings is *WEIGHT BOLD*, as you wrote. 
>> What string gets fed into declutter_style()?   declutter_style() uses 
>> the string in the method call param = 
>> c.styleSheetManager.expand_css_constants(arg).split()[0].   Every string 
>> I've given that method returns the same string, or the first word of it. 
>> None of those strings exist of attributes of QFont, so the default always 
>> comes back, which is 75.
>>
>> Anyway, 700 is the value to use for bold, not 75.  It's an integer, not a 
>> string.
>>
>> On Thursday, October 31, 2024 at 9:23:44 AM UTC-4 jkn wrote:
>>
>>> it is the getting of the argument, from eg:
>>>
>>> # part of declutter-pattern
>>> WEIGHT 700
>>> or ?
>>> WEIGHT Bold     # as per documentation
>>>
>>> => "arg = 700"
>>>
>>> that is not working, I think.
>>>
>>> On Thursday, October 31, 2024 at 1:15:28 PM UTC [email protected] wrote:
>>>
>>>> On Thursday, October 31, 2024 at 7:45:05 AM UTC-4 Thomas Passin wrote:
>>>>
>>>> Either of these work in the sense of executing without producing an 
>>>> error.  I haven't tried applying the font to see the results:
>>>>
>>>> from leo.core.leoQt import QtGui, QtWidgets
>>>> QFont = QtGui.QFont
>>>>
>>>> newfont = QFont('Georgia')
>>>> newfont.setWeight(QFont.Weight.Bold)
>>>> # or
>>>> newfont.setWeight(700)
>>>>
>>>>
>>>> Now I've tried it and yes, I do get bold text.  That detour with arg = 
>>>> getAttr() isn't needed.
>>>>  
>>>>
>>>>
>>>> On Wednesday, October 30, 2024 at 2:58:37 PM UTC-4 jkn wrote:
>>>>
>>>> ... I see that the values for the Weight enum for QFont.setWeight() 
>>>> seem to have changed for PyQt6. It is now a scale of 1 to 1000, instead of 
>>>> 1 to 99 as previously.
>>>>
>>>> https://doc.qt.io/qt-6/qfont.html#Weight-enum
>>>>
>>>> Changing this in qt_tree helps:
>>>>
>>>> --- a/leo/plugins/qt_tree.py 
>>>> +++ b/leo/plugins/qt_tree.py 
>>>> @@ -307,7 +307,7 @@ class LeoQtTree(leoFrame.LeoTree): 
>>>>             elif cmd == 'WEIGHT': 
>>>>  
>>>>                 def weight_modifier(item: Item, param: str) -> None: 
>>>> -                    arg = getattr(QtGui.QFont, param, 75) 
>>>> +                    arg = getattr(QtGui.QFont, param, 700) # WAS 75 
>>>>                     font = item.font(0) 
>>>>                     font.setWeight(arg) 
>>>>                     item.setFont(0, font)
>>>>
>>>>

-- 
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/5ec1ba11-2e74-48e2-bf31-9cafd85ede47n%40googlegroups.com.

Reply via email to