[Tkinter-discuss] listbox formatting

Cameron Laird Cameron at phaseit.net
Mon Aug 21 00:15:03 CEST 2006


On Sun, Aug 20, 2006 at 01:35:32AM -0400, Jeff Cagle wrote:
			.
			.
			.
> I have strings that are composed of multiple properties within an 
> object.  I wanted to format the strings so that they came out nicely in 
> a listbox.  However, listbox widgets choke on the '\t' character, so I 
> tried to roll my own:
> 
> def get_lbstring(self):
>   s = self.datestring
>   return s + " " * (20 - len(s)) + self.name
> 
> unfortunately, listboxes *also* have variable-width fonts (at least as 
> the default).  Short of changing to Courier font, is there a way to get 
> items to line up in a listbox?
			.
			.
			.
Let's be precise:  do listboxes treat \t as ' '?  Is
that what you mean by "choke"?

To get items to line up in a listbox ... well, the
easiest way is to use someone else's work.  Look into
one of the table widgets or extensions.  I like the 
tablelist for Tk work; I haven't had occasion yet to
wrap it for use in Tkinter.


More information about the Tkinter-discuss mailing list