Tkinter families() not working

Javier Bezos see.below at no.spam.es
Sun May 6 04:26:34 EDT 2001


Hi all,

I'm having a problem when I try to get the list of
available fonts using the families() function provided
by Tkinter. The following program:
----------
from Tkinter import *
from tkFont import *

root = Tk()

f = Font(family="times")
print f.actual("family")

print names()

x = families()  # ???
----------
produces:
----------
Times
('font11003664',)
Traceback (most recent call last):
  File "Programación:Python 2.0:font.py", line 11, in ?
    x = families()  # ???
  File "programación:python 2.0:lib:lib-tk:tkFont.py", line 146, in
families
    return root.tk.splitlist(root.tk.call("font", "families"))     
UnicodeError: ASCII encoding error: ordinal not in range(128)
----------
What's wrong? The following code (I'm using MacPython 2.0) works fine:
----------
import Res
fontnames = []
for i in range(1, Res.CountResources('FOND') + 1):
        r = Res.GetIndResource('FOND', i)
        fontnames.append(r.GetResInfo()[2])

print fontnames
----------
as well as the line:  set c [font families]   in wish (tcl/tk).

Thanks a lot in advance for the answers.

Javier
___________________________________________________________
Javier Bezos              | TeX y tipografia
jbezos at wanadoo dot es  | http://perso.wanadoo.es/jbezos/




More information about the Python-list mailing list