1

I have a Text widget in Ubuntu 22.04 and I want to write Farsi in it but it not work properly with Farsi letters, I used add_bidi_support from awesometkinter lib but for entry widget ,the library does not have any function for Text widget.

description_text = tk.Text(record_tab, width=15,height=5 ,font=("B Nazanin",20))
description_text.tag_config('tag-right', justify='right')
description_text.grid(row=3, column=0, padx=20, pady=20)

enter image description here

it has to be like this : سلام

I tried

awesometkinter

1 Answers1

1

You have use the Tkinter.Text.tag_config method. However, I am not sure if your Arabic characters salam has configured as the tab-right. If your word is out-of-tag, the font request will be ignored.

Let say simplier. You fired up a Word document. You typed text inside it and then set the blank line into different font. You won't see your text changing the font too. That's the same theory.

Then, how to solve this problem? Easy. Add a tag to it.

import tkinter as tk
from tkinter import ttk

root = tk.Tk()
root.title("Misinahaiya's solution")

record_tab = ttk.Notebook(root)
record_tab.pack(expand=True)

description_text = tk.Text(record_tab, width=15, height=5, font=("B Nazanin", 20))
description_text.insert("1.0", "سلام")
description_text.tag_add("tag-right", "1.0", tk.END) # <- MAIN POINT!!!
description_text.tag_config('tag-right', justify='right')
description_text.grid(row=3, column=0, padx=20, pady=20)

root.mainloop()
Misinahaiya
  • 502
  • 2
  • 17