python - Tkinter Label: How do I know that the text is too long for it? -


let me explain. have label. fixed size. , i'd know if there way let me know whether text want display in label long it.

len() not since not characters of same width.

why ? have label next showing << when happens, solved len() thats not good.

you can use font_measure determine how many pixels required particular string in particular font on particular screen.

... text="hello, world" default_font = tkfont.nametofont("tkdefaultfont") width = default_font.measure(text) height = default_font.metrics("linespace") ... 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -