.
import tkinter as tk
root = tk.Tk()
label = tk.Label(root)
listbox = tk.Listbox(root)
label.pack(side="bottom", fill="x")
listbox.pack(side="top", fill="both", expand=True)
listbox.insert("end", "one", "two", "three", "four", "five")
def callback(event):
selection = event.widget.curselection()
if selection:
index = selection[0]
data = event.widget.get(index)
label.configure(text=data)
else:
label.configure(text="")
listbox.bind("<<ListboxSelect>>", callback)
root.mainloop()
I have the above code fro net whci prints the value of the lsit box item when selected. I want to use this value outside the function I mean in the main code. for xampe I want use it an expression like xprsn = 'any thing' + the retirned value by the callback function. in other words can I establish the value without function and how can I use that that value without functions? Thanks
[edit by admin: formatting]