[Tkinter-discuss] more control over truncating long strings in Labels?

Russell E. Owen rowen at cesmail.net
Wed Apr 27 20:33:49 CEST 2005


I'd was wondering if there was some fairly easy way to display text in a 
Label such that it is is anchored on the west (short strings are against 
the left edge), but too-long strings are truncated on the left. This 
would be useful for displaying very long path names. It might be even 
nicer to truncate the text in the middle, replacing the excess text with 
..., but truncating on the left would be fine.

I fear the only way is to use font metrics (using a tkFont object from 
the tkFont module) and iteratively try to figure out what length of 
string will fit. If so, it sounds messy. Hope I'm missing something.

-- Russell



More information about the Tkinter-discuss mailing list