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

Stewart Midwinter stewart.midwinter at gmail.com
Fri Sep 15 01:29:31 CEST 2006

Sumanth, if you put your entry data into a StringVar or IntVar, it will be
available for use elsewhere in the application.  You can combine this with
the textvariable parameter, as discussed in example 8-5 in Grayson's book
Python and Tkinter Programming. all his examples are available here:
http://www.manning.com/grayson/ and the book is recommended.

here's his example 8-5:

from Tkinter import *

class Var(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)

        self.field = Entry()

        self.value = StringVar()
        self.value.set("Jean-Paul Sartre")
        self.field["textvariable"] = self.value

        self.field.bind('<Key-Return>', self.print_value)

    def print_value(self, event):
        print 'Value is "%s"' % self.value.get()

test = Var()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tkinter-discuss/attachments/20060914/0807bc71/attachment.htm 

More information about the Tkinter-discuss mailing list