How to align text to the right in ttk Treeview widget?

peterv picture peterv · May 22, 2015 · Viewed 10.4k times · Source

I am using a ttk.Treeview widget to display a list of Arabic books. Arabic is a right-to-left language, so the text should be aligned to the right. The justify option that is available for Label and other ttk widgets does not seem to work for Treeview.

Does anyone know how to do this?

Answer

fhdrsdg picture fhdrsdg · May 22, 2015

The ttk.Treeview widget has an anchor option you can set for each column. To set the anchor of a column to the right side use:

ttk.Treeview.column(column_id, anchor=Tkinter.E)