0
參考Is it possible to colour a specific item in a Listbox widget?是否可以根據列表中保存的數據更改bg顏色。更改Tkinter列表框中項目的顏色
例如:
在列表名有幾個值,一些積極的,別人負。我想根據它們的正面或負面來改變它們的背景顏色。
if names > 0 :
diffbox.itemconfig(bg='red')
if names < 0 :
diffbox.itemconfig(bg='green')
diffbox.insert(END, names)
非常感謝!很有幫助 –