[Tutor] system error trapping

Rick Pasotto rick at niof.net
Fri Aug 27 21:15:41 CEST 2004


I'm trying to write a little program to display all the fonts available
on my system. It works for the most part but some of the fonts are
evidently defective and Xwindows returns an error that try/except
doesn't catch. How can I skip these fonts?

Here is the code section:

    try:
        Label(root,font=fn,text=txt,background='white',relief='groove',
                borderwidth=3).grid(row=rw,column=1)
        Label(root,text=ff,background='white').grid(row=rw,column=0)
        print "did ",fn
    except:
        print "oops, didn't work ",fn


For some fonts the script exits with this traceback:

X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  45 (X_OpenFont)
  Value in failed request:  0x2200019
  Serial number of failed request:  78
  Current serial number in output stream:  79

-- 
"Law never made men a whit more just; and, by means of their respect for
 it, even the well-disposed are daily made the agents of injustice."
	-- Henry David Thoreau
    Rick Pasotto    rick at niof.net    http://www.niof.net


More information about the Tutor mailing list