[Tkinter-discuss] handling of item selected in the listbox

sumanth_scl Sumanth.Thallam at wabco-auto.com
Thu Sep 14 10:15:42 CEST 2006

hello friends.... i am new to forum, and i got a problem while using tkinter
GUI with python.My script performs some initial operations and calls the
result ot the operation to be displayed in listbox, and depending on
selection of user input, the program should again proceede with some more
operations. but the variable where i stored the input given by user to
listbox is unable to hold that value if the processing is not in the GUI
part.... can any one suggest solution for this. i am giving the part of
python program for ur understanding the problem..

from Tkinter import *

def whichselected() :
    return int(select.curselection()[0])
def loadEntry () :
    print temp_name

def makeWindow () :
    global nameVar, select
    win = Tk()

    frame1 = Frame(win)

    Label(frame1, text="List of Variants (please select the variant to be
analysed)").grid(row=0, column=0, sticky=W)
    frame3 = Frame(win)       # select of names
    select = Listbox(frame3, height=22, width=85)

    frame2 = Frame(win)
    b1.grid(row=2, column=0, sticky=W)
    return win    
def setSelect () :
    for name in Total_variants:
        select.insert (END, name)

def user_variant ():
    win = makeWindow()
    setSelect ()
    print temp_name

The script will run and collect some variants and store them in
Total_variants , which is global variable and the script will
now the problem is temp_name in function loadEntry () will give the exact
thing selected by the user, the print temp_name in the function
user_variant() will give error , not defined. If i define it as global then
the value assaigned to it will print or some junk is printed and not the
user selected thing. actually i want to use temp_name in later part of the
program, but i m getting the error not defined. can any one give me the
solution how to handle this.
View this message in context: http://www.nabble.com/handling-of-item-selected-in-the-listbox-tf2270206.html#a6301312
Sent from the Python - tkinter-discuss forum at Nabble.com.

More information about the Tkinter-discuss mailing list