This script shows how it is possible to put a list into a listbox, without having to iterate trough one, but just doing so:
- create a list
- add the list as value into StringVar (or IntVar)
- add as listvariable argument the istance of StringVar
import tkinter as tk import tkinter.ttk as ttk root = tk.Tk() root.geometry("400x400") food_list = ['apple', 'banana', 'orange'] list1 = tk.StringVar(value=food_list) lst = tk.Listbox(root, listvariable=list1) lst.pack() root.mainloop()
Subscribe to the newsletter for updates
Tkinter templates
My youtube channel
Twitter: @pythonprogrammi - python_pygame