My question is simple, I'm a begginer in PySimpleGUI, and I want to know how do I change the color of text in a list box, but i want to change only some specific lines, so it's important that I can run all the list and select the lines. Someone know how to do that, I'll be very thankfull.
tkinter code required to set options for items in listbox.

import PySimpleGUI as sg
sg.theme("DarkBlue")
items = ['USA', 'Mexico', 'Japan', 'Korea', 'UK', 'China', 'France']
asia_index = (2 ,3, 5)
layout = [
[sg.Listbox(items, size=(10, 7), key='-LISTBOX-')],
]
window = sg.Window('Title', layout, finalize=True)
listbox = window['-LISTBOX-'].Widget
for index in asia_index:
listbox.itemconfigure(index, bg='green', fg='white') # set options for item in listbox
while True:
event, values = window.read()
if event == sg.WINDOW_CLOSED:
break
print(event, values)
window.close()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With