Python and Tkinter - Listbox, how to add and delete items

preview_player
Показать описание
How to add items and how to delete them into a listbox using Python and Tkitner

New post with an updated code

The code with chance to save data

import tkinter as tk

root = tk.Tk()

def retrievedata():
global list_data
list_data = []
try:
for f in file:
print(list_data)
except:
pass

def clicked():
global list_data

def delete():
global list_data
list_data = []

def delete_selected():
global list_data

try:
#print(index)
except:
pass

def quit():
global root
for d in list_data:

# LISTBOX

content = tk.StringVar()
entry = tk.Entry(root, textvariable=content)

button = tk.Button(root, text="Add Item", command=clicked)

button_delete = tk.Button(text="Delete", command=delete)

button_delete_selected = tk.Button(text="Delete Selected", command=delete_selected)

listbox = tk.Listbox(root)

bquit = tk.Button(root, text="Quit and save", command=quit)

retrievedata()
Рекомендации по теме
Комментарии
Автор

Can you do a video how to put records from database sqlite or MySql into listbox. Thanks

dannyyeoh
Автор

Instead of add these items to listbox, how also you can add to combobox

nanyaroelisha
Автор

How can you save the entries for next time you run the program?

mp