This is not a big issue, however it bugs me. It seems that the text within the cells of the first column #0
of ttk.Treeview
is shifted downard. The result is not very clean, as part of the text is hided.
import tkinter as tk
import tkinter.ttk as ttk
root = tk.Tk()
root.geometry("500x900")
choices = ("Author", "John", "Mohan", "James", "Ankur", "Robert")
master_frame = ttk.Frame(root)
master_frame.pack(expand = True, fill = "both")
tree = ttk.Treeview(master_frame)
tree["columns"]=("Test1", "Test2")
tree.pack(fill = "both")
for item in choices:
tree.insert('', 'end',item ,text = item,
values = (item, "Hello_W0rld"))
message_txt = tk.StringVar()
def what():
message_txt.set(", ".join(tree.selection()))
ttk.Button(master_frame, text = "Name it!",
command = what).pack()
ttk.Label(master_frame, textvariable = message_txt).pack()
root.mainloop()
Result of the previous code: the text is partially hided in the first column of the Treeview
Am I doing something wrong? If not , are there solutions? For instance, is there a way to have control over the width of a row? Or simply the anchor of the text whithin a cell? Thanks in advance, have a nice day.
treestyle = ttk.Style()
treestyle.theme_use("clam")
treestyle.configure("Treeview",
rowheight=30)