Morten Larsen
Morten Larsen

Reputation: 503

How to set the color of items in a listbox

I am making a Listbox which should contain lines from two lists.

Here is my rough draft:

LISTBOX = Listbox(master)

for line in LIST1:
    for lin in LIST2:
        LISTBOX.insert(END, line)
        LISTBOX.insert(END, lin)

Now, I want the lines from LIST1 to be marked (highlighted in blue) automatically in the listbox. Is this possible?

Upvotes: 1

Views: 2346

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386020

You can do something like this:

LISTBOX.insert(END, line)
LISTBOX.itemconfigure(END, background="blue")

Upvotes: 2

Related Questions