1 year ago
#388609
RtxTrillihin
How to display Russian language in Tkinter text widget? (Currently only seeing unicode)
Does anybody know what my problem is? I'm starting some work on tkinter and when I copy/paste a bit of Russian Text to my tkinter text widget it looks like this
Here is the original text
Лиса вышла холодной ночью. Он молился, чтобы луна дала ему свет. Ибо в ту ночь ему предстояло пройти много миль.
Can someone help me correctly display this text on tkinter?
some information.
- I am using a conda environment
- python 3.7
- OS is CentOS
Steps to reproduce my environment.
setup a conda environment (my python version is 3.7) https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html
set conda environment as interpreter in pycharm
code
import tkinter as tk window = tk.Tk() txt_align = tk.Text(master=window) txt_align.grid(sticky="nsew", padx=5, pady=5) window.mainloop()
if you want you can also do
text = "Лиса вышла холодной ночью. Он молился, чтобы луна дала ему свет. Ибо в ту ночь ему предстояло пройти много миль."
txt_align.insert(tk.END, text)
print(text)
but my results stay the same unfortunately.
copy russian text Лиса вышла холодной ночью. Он молился, чтобы луна дала ему свет. Ибо в ту ночь ему предстояло пройти много миль.
paste it into tkinter text box
things I've tried:
- I tried importing codecs and opening my text file containing the Russian text that way with encoding = utf-8
More info: When I 'get' the text from the text widget and print to console, it displays Russian just fine. -English,French works just fine but Korean, Chinese, arabic all display in this weird format
Thank you!
linux
tkinter
unicode
fonts
tkinter-text
0 Answers
Your Answer