Tkinter changes unicode character on input

38 Views Asked by At

When I write a word ی in tkinter textarea it becomes ي what is the problem. Here is the textarea code.

from tkinter import font
def submit_text():
text_to_display = input_text.get("1.0", "end-1c")
output_text.delete("1.0", tk.END)
output_text.insert("1.0", text_to_display, "rtl_tag")

def on_keypress(event):
current_position = input_text.index(tk.INSERT)
input_text.tag_configure("rtl_tag", justify='right')
input_text.tag_add("rtl_tag", "1.0", "end")
input_text.mark_set(tk.INSERT, current_position)

# Create main window
root = tk.Tk()
1

There are 1 best solutions below

0
toyota Supra On

Is this what it looks like?

Using encode('utf8').

Snippet:

import tkinter as tk

root = tk.Tk()

from tkinter import font
def submit_text():
    a = 'ی'
    #text_to_display = input_text.get("1.0", "ی")
    input_text.delete("1.0", tk.END)
    input_text.insert("1.0", a.encode('utf8'))

font = "Comic Sans MS", 20, "bold"
input_text = tk.Text(root, font=font)
input_text.pack()
submit_text()    

root = tk.Tk()

Screenshot:

enter image description here