A listbox shows a list of options. You can then click on any of those options. By default it won’t do anything, but you can link that to a callback function or link a button click.

To add new items, you can use the insert() method. This accepts a single parameter or a list of items.

Related course:
Python Desktop Apps with Tkinter
icon

tkinter listbox

If you have multiple items, you can use listbox. The tkinter listbox example below shows different items. This is an interactive program, you can click around and change the values.

This is not a combobox, see screenshot below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import tkinter as tk

window = tk.Tk()
window.title('My Window')

window.geometry('500x300')

var1 = tk.StringVar()
l = tk.Label(window, bg='green', fg='yellow',font=('Arial', 12), width=10, textvariable=var1)
l.pack()

def print_selection():
value = lb.get(lb.curselection())
var1.set(value)

b1 = tk.Button(window, text='print selection', width=15, height=2, command=print_selection)
b1.pack()

var2 = tk.StringVar()
var2.set((1,2,3,4))
lb = tk.Listbox(window, listvariable=var2)

list_items = [11,22,33,44]
for item in list_items:
lb.insert('end', item)
lb.insert(1, 'first')
lb.insert(2, 'second')
lb.delete(2)
lb.pack()

window.mainloop()

tkinter listbox