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/ff9a0ec7-7b99-4f7f-b529-b9f6dcb0cf11n%40googlegroups.com.
