[Tkinter-discuss] Get height of a row in Treeview in Tkinter with Python3

Michael Lange klappnase at web.de
Thu Feb 15 14:43:28 EST 2018


Hi,

On Tue, 13 Feb 2018 22:00:48 +0100
<c.buhtz at posteo.jp> wrote:

> X-Post: https://stackoverflow.com/q/48736168/4865723
> 
> I want to know how height (in pixel) is a row in a tkinter.Treeview.
> 
> I know how I can manipulate the height (see example below) with the
> styling mechanism. But I want to read it first - because it depends on
> the operating system, fonts, etc. And I couldn't find something in the
> style object I could read for this.
> 
> My goal is to modify the rowheight with a relative factor. e.g. 1,5 of
> the original height.

I never used the rowheight option myself, so I don't know for sure. I
figure that by default the rowheight is not set explicitely and thus the
widget will assign the required height for each row individually (for
example different sized icons might lead to different row heights);
probably when rowheight is explicitely given all rows will be the same
height, regardless of their contents (is this correct?).

Now, if you assume that in your case all rows have the same height,
I think using bbox(someitem)[3] should deliver the value you want (maybe
with one or two extra pixels added for borders). However if the heights of
the rows differ, this value might probably lead to rather disappointing
results :)

Best regards

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

Even historians fail to learn from history -- they repeat the same
mistakes.
		-- John Gill, "Patterns of Force", stardate 2534.7


More information about the Tkinter-discuss mailing list