Tkinter Listbox - Different Text colors in one listbox

rahulnag22 at yahoo.com rahulnag22 at yahoo.com
Wed May 30 12:48:22 EDT 2007


On May 30, 6:04 am, rfg... at gmail.com wrote:
> On May 29, 2:02 pm, rahulna... at yahoo.com wrote:
>
> > Hi,
> > Is it possible to havedifferentitems in alistboxindifferentcolors? Or is it justonecolor for all items in alistbox?
> > Thanks
> > Rahul
>
> from Tkinter import *
>
> root = Tk()
> l = Listbox(root)
> l.pack()
> for x in range(10):
>     l.insert(END, x)
> l.itemconfig(2, bg='red', fg='white')
> l.itemconfig(4, bg='green', fg='white')
> l.itemconfig(5, bg='cyan', fg='white')
> root.mainloop()
>
> You can _only_ configurate 'background', 'foreground',
> 'selectbackground', 'selectforegroud', not font :(
>
> HTH

Thanks for the feedback all. I tried the itemconfig method and it
works great.
Thanks




More information about the Python-list mailing list