Tkinter Listbox - Different Text colors in one listbox

rfg007 at gmail.com rfg007 at gmail.com
Wed May 30 08:04:52 EDT 2007


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




More information about the Python-list mailing list