Tal Einat <taleinat+pyt...@gmail.com> added the comment: This is at least partly a tcl/tk issue.
Using Terry's last example, the Text widget reports that the length of the line is 14 (t.index('1.end') -> '1.14'), despite it only including 11 characters. It appears that each emoji character adds an extra character. Minimal reproducer: >>> t.delete('1.0', 'end') >>> t.insert('1.0', 'a') >>> t.index('1.end') '1.1' >>> t.delete('1.0', 'end') >>> t.insert('1.0', '😀') >>> t.index('1.end') '1.2' The same happens when using tcl/tk directly, so it's not a tkinter issue: $ wish % tk::text .t -width 40 -height 5 -wrap none -yscrollcommand ".ys set" -xscrollcommand ".xs set" .t % ttk::scrollbar .ys -orient vertical -command ".t yview" .ys % ttk::scrollbar .xs -orient horizontal -command ".t xview".t extra characters after close-quote % ttk::scrollbar .xs -orient horizontal -command ".t xview" .xs % .t insert end "a" % grid .t -column 0 -row 0 -sticky nwes % grid .t -column 0 -row 0 -sticky nwes % grid .ys -column 1 -row 0 -sticky ns % grid columnconfigure . 0 -weight 1 % grid rowconfigure . 0 -weight 1 % .t delete 1.0 end % .t insert end "😀" % .t index 1.end 1.2 % .t get 1.0 😀 ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44217> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com