[PyKDE] Converting font names to python strings

Giovanni Bajo rasky at develer.com
Tue Apr 19 15:02:58 BST 2005

Jeremy Sanders <jeremy at jeremysanders.net> wrote:

>> You could use unicode(i) to convert QString to a Python unicode string.
>> Either that, or keep the QString. It pretty much depends on what you are
>> going to do with that families dict.
> Excellent. I'm doing things like
> if 'Times New Roman' in families:
>     # do something I shouldn't here
> to check whether we have fonts installed.
> So as long as that works (which it appears to do), it should be okay...

Sure. To double check, you can use the good ol' interactive shell:

>>> a = {}
>>> a[u'ciao'] = True
>>> u'ciao' in a
>>> 'ciao' in a
>>> a
{u'ciao': True}

Giovanni Bajo

More information about the PyQt mailing list