How to fully change the color of a Tkinter Listbox?

TkinterPythonGUI-Programming

Tkinter Listbox widgets are very useful in the case of representing a large set of data items in form of list items. To configure the properties such as change the background color of the entire Listbox, we can use configure(**options) method to change the properties of the Listbox widget.

Example

# Import the required libraries
from tkinter import *

# Create an instance of tkinter frame or window
win=Tk()

# Set the size of the window
win.geometry("700x350")

# Add a Listbox widget with number as the list items
listbox =Listbox(win)
listbox.insert(END,"C++", "Java", "Python", "Rust", "GoLang", "Ruby", "JavScript", "C# ", "SQL", "Dart")
listbox.pack(side=LEFT, fill=BOTH)

listbox.configure(background="skyblue4", foreground="white", font=('Aerial 13'))

win.mainloop()

Output

Running the above code will display a customized Listbox with some list items in it.

raja
Published on 18-Jun-2021 14:13:06
Advertisements