Skip to content

Instantly share code, notes, and snippets.



Last active Jul 14, 2020
What would you like to do?
my simple tkinter Listbox GUI
def simple_tklb(fn_get_list, fn_double_click_item):
from tkinter import Tk, Listbox
tk = Tk()
lb = Listbox(tk)
for idx, item in enumerate(fn_get_list()):
lb.insert(idx, item)
def onselect(event):
if fn_double_click_item:
w = event.widget
index = int(w.curselection()[0])
value = w.get(index)
fn_double_click_item(index, value)
lb.bind('<Double-1>', onselect)
lb.config(width=0, height=0)
if __name__ == '__main__':
def fn_get_list():
return ('aaaaaaaaaa', 'bbbbbbbb', 'cccccccc')
def fn_double_click_item(idx, item):
print(f'idx: {idx}; item: {item}')
simple_tklb(fn_get_list, fn_double_click_item)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.