On 03/11/2020 03:04, Terry Reedy wrote:
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:

I'm not sure about the purpose of the tk variable here but hey ho.

     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)


Did you mean your 'print' here or did you intend the builtin 'print'? I assumed the latter so just renamed your 'print' to 'tkprint'.

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?


Ran to completion on ubuntu in negligible time using python3.7 and 3.8.

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

_______________________________________________
IDLE-dev mailing list
IDLE-dev@python.org
https://mail.python.org/mailman/listinfo/idle-dev

Reply via email to