Last active
July 14, 2020 11:26
-
-
Save gooooloo/14b2ed08502625240fe443c655c8758d to your computer and use it in GitHub Desktop.
my simple tkinter Listbox GUI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
lb.pack() | |
tk.mainloop() | |
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