0

Please forgive my questions and my previous reactions. I have spent time at SO in Spanish and have learned a lot.
Also, I no longer take negative votes as badly as I used to.
Here is my question c:


I have the following code in which I create a treeview whose values span multiple lines.

from tkinter import ttk

tree = ttk.Treeview(columns=(0,))
tree.column("#0", width=0)
tree.column(0, width=100)

tree.insert("", "end", values=("text1\ntext2",))
tree.insert("", "end", values=("text3",))

tree.pack()

However, it looks like this:

https://i.stack.imgur.com/HYT37.png

As I suppose you can see, the content of the second row covers part of the content of the first.

Googling, I came across this question whose answers are the closest to what I'm looking for: ttk.Treeview - Can't change row height.

However, what I want to achieve is that each row has a different height which depends on how many lines the text contains. I did not find any page that talks about it by googling.

What I want to achieve is make the treeview look like this:

Does anyone have any ideas to be able to achieve what I am looking for?

Dante S.
  • 222
  • 3
  • 16

1 Answers1

0

I have found the solution to this. You need to set a style for the treeview and use the rowheight item, changing the height of a each row. But as there are some complications doing this, I found a relevant thread which discusses implementation.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 21 '22 at 17:30