在 Tkinter Python 中测量字符串的高度? [英] Measure the height of a string in Tkinter Python?
本文介绍了在 Tkinter Python 中测量字符串的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要 Tkiner 小部件中字符串的像素高度.它是 Listbox
一行中的文本.
I need the height in pixel of a string in a Tkiner widget. It is the text in a row of a Listbox
.
我知道我可以使用 tkinter.font.Font.measure
测量字符串的宽度.但是我怎样才能得到高度呢?类似问题仅将宽度主题化,而不是高度主题化.
I know I can measure the width of a string with tkinter.font.Font.measure
. But how can I get the height?
A similar question thematised only the width but not the height.
推荐答案
这可以解决问题.
tkinter.font.Font(font='TkDefaultFont').metrics('linespace')
这篇关于在 Tkinter Python 中测量字符串的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文