How do you do this in python with tk?

Jeff Epler jepler at
Fri Oct 8 01:44:13 CEST 2004

You could create a Text widget and insert lines of text in it.

import Tkinter
def add_rows(w, titles, rows):
    for r in rows:
        for t, v in zip(titles, r):
            w.insert("end", "%s:\t%s\n" % (t, v))
        w.insert("end", "\n")

app = Tkinter.Tk()
t = Tkinter.Text(app)
info = [['Ali',18],
add_rows(t, ["Name", "Age"], info)

If there are many lines, you can use a scrollbar widget to scroll the
text widget.  You can use the tabs= argument of the Text widget to
adjust the alignment of the second column.  If you want to make the
items "interactive", you can use tags and tag_bind to react to things
like button presses.  You can set the text widget to be "disabled" to
keep the user from changing the contents.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <>

More information about the Python-list mailing list