I need just to replace the name of font as RSQFont if value 123 or Regular if not value .. So I have this code ...
if 123.value:
FontName='RSQFont'
else:
FontName='Regular'
"""<screen backgroundColor="#16000000" name="AGC_Picon" position="210,130" size="800,470" title="Quick Signal Info" zPosition="1" flags="wfNoBorder">
<widget source="Title" render="Label" font="%(key)s;23" foregroundColor="#00bbbbbb" position="0,0" size="350,30" transparent="1" />
<widget source="global.CurrentTime" render="Label" position="545,0" size="250,30" font="%(key)s;23" valign="top" halign="left" foregroundColor="#00bbbbbb" transparent="1">
<convert type="ClockToText">Format:%d-%m-%Y %H:%M:%S</convert>
</widget>
<widget source="session.CurrentService" render="Label" position="599,403" size="200,25" font="%(key)s; 20" halign="center" backgroundColor="#54111112" foregroundColor="#fec000" transparent="1">
<convert type="RaedQuickServName2">%F %p %Y %M %s</convert>
</widget>
<widget source="session.CurrentService" render="Label" position="599,435" size="200,23" font="%(key)s; 18" halign="center" backgroundColor="#54111112" foregroundColor="#00bbbbbb" transparent="1">
<convert type="RaedQuickServName2">%c %l %h %m %g %b %e %S</convert>
</widget>
<widget name="Satfinder" position="5,319" size="300,18" zPosition="1" font="%(key)s;17" halign="left" backgroundColor="#54111112" foregroundColor="#0000deff" transparent="1" />
</screen>""" % {'key': FontName,}
But I have got this error
""" % {'key': FontName,}
TypeError: not enough arguments for format string
I tried different method but I can not solve it ...
I have tried
.format(FontName)
instead of
{'key': FontName,}
And other things but nothing to help ... and advice ?!!!
P.s: I cannot use %s code because some lines already have and use it with other python files as like this
<convert type="RaedQuickServName2">%F %p %Y %M %s</convert>
and
<convert type="ClockToText">Format:%d-%m-%Y %H:%M:%S</convert>
str.format(), instead of old-style string formatting or even template engine likejinja2?%characters which Python's%string operator interprets. To work around it you would need to "escape" all the other%characters by doubling them (so the%string operator could turn them back into single characters). A simpler workaround would be to use the more modernstr.format()method that uses{and}characters (as @buran suggested already).{and}characters) would be to use f-strings which were added in Python 3.6.font="{0};23"you would only have to passFontNameonce.