Please help test astral char display in tkinter Text (especially *nix)

Terry Reedy tjreedy at udel.edu
Mon Nov 2 22:04:17 EST 2020


tcl/tk supports unicode chars in the BMP (Basic Multilingual Plane, 
utf-8 encoded with 1-3 bytes).  The presence of chars in other plains 
('astral', utf-8 encoded with 4 bytes, I believe) in a tkinter Text 
widget messages up *editing*, but they can sometimes be displayed with 
appropriate glyphs.

On my Windows 10 64-bit 2004 update, astral code points print as 
unassigned [X], replaced [], or proper glyphs (see below).  On my 
up-to-date macOS Mohave, as far as I know, no glyphs are actually 
printed and some hang, freezing IDLE's Shell (and making extensive 
testing difficult).  On Linux, behavior is mixed, including 'crashes', 
with the use of multicolor rather than black/white fonts apparently an 
issue.  https://bugs.python.org/issue42225.  I would like more 
information about behavior on other systems, especially *nix.

The following runs to completion for me, without errors, in about 1 second.

tk = True
if tk:
     from tkinter import Tk
     from tkinter.scrolledtext import ScrolledText
     root = Tk()
     text = ScrolledText(root, width=80, height=40)
     text.pack()
     def print(txt):
         text.insert('insert', txt+'\n')

errors = []
for i in range(0x10000, 0x40000, 32):
     chars = ''.join(chr(i+j) for j in range(32))
     try:
        print(f"{hex(i)} {chars}")
     except Exception as e:
         errors.append(f"{hex(i)} {e}")
print("ERRORS:")
for line in errors:
     print(line)

Perhaps half of the assigned chars in the first plane are printed 
instead of being replaced with a narrow box. This includes emoticons as 
foreground color outlines on background color.  Maybe all of the second 
plane of extended CJK chars are printed.  The third plane is unassigned 
and prints as unassigned boxes (with an X).

If you get errors, how many.  If you get a hang or crash, how far did 
the program get?

-- 
Terry Jan Reedy



More information about the Python-list mailing list