I wrote the following code:
    import Tkinter
    t = Tkinter.Label()
    t.configure(
        text=u"As the function approaches \N{INFINITY}, \N{HORIZONTAL 
ELLIPSIS}")
    t.pack()
    t.mainloop()
It worked for me on Windows NT 4.0 with Python 2.4, and on RedHat 9 with
a self-compiled Python 2.3, showing an infinity symbol and an ellipsis.

u'\N{...}' stands for the Unicode character named '...'.  Unicode.org
(and other sites) have lists of Unicode character names. 

Tk tries very hard to find the requested character in some font
available on the system, but when it fails it just displays a unicode
escape sequence like "\u220e" (instead of the END OF PROOF symbol, in
this case), and there's really no way for Python to find out and fall
back in some graceful way.

Relying on this behavior, here's a somewhat-falliable way to detect the
presence of a symbol in the font used in a given widget:
    def symbol_exists(s, w, f = None):
        if f is None:
            f = w.cget("font")
        width_symbol = w.tk.call("font", "measure", f, s)
        width_bench = w.tk.call("font", "measure", f, "000")
        return width_symbol < width_bench
This finds the width in pixels of the given symbol (s) and the string "000", in
the font f.  If the width of the symbol is smaller, then it's probably 
available.
If it's wider, then it's probably rendered as an escape sequence like "\u220e".
This is falliable because there's no guarantee that the symbol would not be as
wide as 000, but also it's possible for some escape code (say \u1111) to be
narrower than 000.  Neither of these seem very likely in practice.

Jeff

Attachment: pgpCovRiRsUh0.pgp
Description: PGP signature

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to