Hi, I guess there's something basic I need to know. Given the code below if I press the button and p and q is highlighted then close the window I get:
Output: >>> dddd [] ('15', '16') dddd [] But the x does not seem to persist outside of the def selected() block. I want the final last button press to persist so I can use those indexes for further processing. What am I missing here? Thanks. import sys, string, Tkinter from Tkinter import * root=Tkinter.Tk() frame=Tkinter.Frame(root) listbox=Listbox(frame, height=27,selectmode=MULTIPLE, font=('courier', 12)) listbox.pack(side=LEFT,fill=BOTH, expand=1) choices=map(chr, range(97, 123)) for item in choices: listbox.insert(END, item) frame.pack(fill=BOTH, expand=1) def selected(): x = listbox.curselection() print x zz='dddd' btn = Button(root, text = "Click for values", command = selected) btn.pack() #test print zz print x root.mainloop() #test print zz print x _______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org http://mail.python.org/mailman/listinfo/tkinter-discuss