This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author taleinat
Recipients erlendaasland, shreyanavigyan, steven.daprano, taleinat, terry.reedy
Date 2021-05-24.04:51:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1621831887.45.0.571806655012.issue44217@roundup.psfhosted.org>
In-reply-to
Content
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
😀
History
Date User Action Args
2021-05-24 04:51:27taleinatsetrecipients: + taleinat, terry.reedy, steven.daprano, erlendaasland, shreyanavigyan
2021-05-24 04:51:27taleinatsetmessageid: <1621831887.45.0.571806655012.issue44217@roundup.psfhosted.org>
2021-05-24 04:51:27taleinatlinkissue44217 messages
2021-05-24 04:51:27taleinatcreate