[Tutor] lists and Entry

Alan Gauld alan.gauld at btinternet.com
Thu Jan 15 01:27:00 CET 2009

"Mr Gerard Kelly" <s4027340 at student.uq.edu.au> wrote

> There is a little Tkinter program. It lets you type something in a 
> box,
> and will display it at the command line.
> e = Entry(master)
> e.pack()

> def callback():
>  s=e.get()
>  print s
> b = Button(master, text="get", width=10, command=callback)

> The get() method returns a string, how do I make it return a list?

You don't. The Entry widget returns a list just like you get when
you use raw_input() in a console program. Its up to you to parse and
convert that string into whatever you require.

You can use other widget types of course and they return slightly
different types of data but they will all generally be string 
An editable list entry can return a list of strings for example...

This is not really a fault of Tkinter BTW, its how nearly all GUIs 
They just capture what the user types and display strings that you
provide. The processing of those input and output strings is the
"business logic" of your program - in other words its up to you!


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list