How do you do this in python with tk?

Eric Brunel eric_brunel at despammed.com
Wed Oct 13 04:01:39 EDT 2004


Ali wrote:
[snip]
> well I tryed this:
> 
> import Tkinter
> def add_rows(w, titles, rows):
>     t.configure(state = 'normal')

REMOVE THAT LINE! Since you use t as a local variable afterwards, this will make 
the whole script fail. BTW, this means this isn't the code you actually used, 
since it doesn't display any window at all.

>     w.configure(state = 'normal')
>     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)
> t.pack()
> info = [['Ali',18],
>         ['Zainab',16],
>         ['Khalid',18]]
> add_rows(t, ["Name", "Age"], info)
> app.mainloop()
> 
> Well... it shows the window, it doesnt show text, it still lets me type in stuff :( 
> What is wrong now?

You never set the text state to disabled, so no wonder you can still type text in...
-- 
- Eric Brunel <eric (underscore) brunel (at) despammed (dot) com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com



More information about the Python-list mailing list