the Georgian language in tkinter. Python

1.1k Views Asked by At

I can not write on a standard Georgian language in the Text widget. instead of letters writes question marks . when no tkinter, ie, when writing code, Georgian font recognized without problems. Plus, if I copy the word written in Georgian and inserted in the text widget, it is displayed correctly.

this is elementary code that displays the text box on the screen, where I want to write a word in Georgian.

import tkinter


root = tkinter.Tk()

txt = tkinter.Text(root)
txt.pack()

root.mainloop()

the first image shows how the word is displayed when the selected Georgian language.

the second shot, when I write in the code in Georgian, and define in advance the value of text field. in this case, the text in the field is displayed normally.

2

There are 2 best solutions below

9
Parviz Karimli On

Okay, so here is how I achieved it:
First, make sure you have a Georgian font installed in your computer; if there is no any, then go download one (I downloaded mine from here);
Now, go to your tkinter program, and add your font to your Text widget:

txt = tkinter.Text(root, font=("AcadNusx", 16))

NOTE 1: My font name that supports Georgian is AcadNusx, but yours can be different;
NOTE 2: If you have not imported Font, then import it at the beginning of your program;
NOTE 3: Do not change your computer's font to Georgian, because you have already changed it inside the program, so make sure it is set to English.

0
Terry Jan Reedy On

The best answer I can determine so far is that there is something about Georgian and keyboard entry that tk does not like, at least not on Windows.

Character 'translation' is usually called 'transliteration'.

Tk text uses the Basic Multilingual Plane (the BMP, the first 2**16 codepoints) of Unicode. This includes the Georgian alphabet. The second image shows that the default Text widget font on your system is quite capable of displaying Georgian characters once the characters are in the widget. So a new display font does not seem to be the solution to your problem. ('ქართული ენა' is visible on Firefox because FF is unicode based and can display most if not all of the BMP.)

It looks like the problem is getting the proper codes to tk without going through your editor. What OS and editor are your using. How did you enter the mixed-alphabet line similar to

txt.insert('1.0', 'ქართული ენა')  # ?  (I cannot copy the image string.)

How are you running the Python code? If you cut the question marks from the first image and insert into

for c in '<insert here>': print(ord(c))

what do you see?

You need a 'Georgian keyboard entry' or 'input method' program (Google shows several) for your OS that will let you switch back and forth between sending ascii and Geargian codes to any program reading the keyboard.

Windows now comes with this, with languages activated on a case-by-case basis. I already had Spanish entry, and with it I can enter á and ñ both here and into IDLE and a fresh Text box. However, when I add Georgian, I can type (randomly ;-) ჰჯჰფგეუგსკფ here (in FireFox, also MS Edge) but only get ?????? in tk Text boxes. And these are actual ascii question marks, ord('?') = 63, rather that replacements for codes that cannot be represented. Japanese also works with tk-Text based IDLE. So the problem with Georgian is not generic to all non-latin alphabets.