The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by jf117]

Hi.
I'm using Tkinter to manage my files using a GUI.
At the moment I'm trying to associate an event to a Listbox.
This is what I'm doing:

------------------------------------------------------------------
def input1():
global listbox,top
top=Toplevel(root)
listbox=Listbox(top)
listbox.pack()
listbox.insert(END,"ICEN")
listbox.bind("<Double-Button-1>",input1key)

def input1key(event):
global listbox,top
listbox.destroy()
top.destroy()
------------------------------------------------------------------------

Now, my question is: how can I associate the string of the selected
Listbox item to a variable? In this case, foe example, I would like
to save "ICEN" to a string x whenever I double-click with the mouse
on ICEN in the listbox.

Anyone can help me?

cheers

james