Indeed - I started doing this before my initial posting, I just have 
limited time windows available. Since we seem to agreed that there is 
something amiss here, I am over my initial question about needing an 
additional package to install as well as PyQt6, and I can experiment from 
there.

Thanks for helping to confirm my suspicions...

    J^n


On Thursday, October 31, 2024 at 4:57:26 PM UTC tbp1...@gmail.com wrote:

> You will probably want to put some print statements into the 
> declutter_style() method to see what arguments get passed when you ask 
> for WEIGHT demibold or whatever. I suspect that nothing you pass in will 
> give any result except the default 75, but that's where the print 
> statements may help.  Even the signature of the method contradicts how the 
> code works. The docstring isn't right, either.  The method probably got 
> massively revised somewhere in the past and a few things got garbled.  
>
> In addition, the line getattr(QtGui.QFont, param,75) queries the QFont 
> class, not the instance actually being used by the item whose font is 
> supposed to be changed, and I don't see how that makes sense. 
>
> So add some print statements  and see if they can help sort it all out.  I 
> don't feel like spending time figuring out how to set up for decluttering 
> in a way that will demonstrate a visibly decluttered headline with bold 
> type.  If I did, print statements would be my starting point.
>
> On Thursday, October 31, 2024 at 12:36:00 PM UTC-4 jkn wrote:
>
>> indeed. My cheap fix is to patch and set the default to 700, as you have 
>> done. But what if I want to see an effect line "WEIGHT DemiBold" for some 
>> declutter patterns?
>>
>> On Thursday, October 31, 2024 at 3:26:40 PM UTC tbp1...@gmail.com wrote:
>>
>>> 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 tbp1...@gmail.com 
>>>> 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 tbp1...@gmail.com 
>>>>>> 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 leo-editor+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/leo-editor/ea424ea6-9a1d-4fe1-b74f-7f0158f0e9e2n%40googlegroups.com.

Reply via email to