How do you do this in python with tk?
Ali
alikakakhel3 at hotmail.com
Wed Oct 13 16:45:26 EDT 2004
Eric Brunel <eric_brunel at despammed.com> wrote in message news:<416cdf1e$0$8640$8fcfb975 at news.wanadoo.fr>...
> 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...
ok so I typed:
import Tkinter
def add_rows(w, titles, rows):
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, state='disabled')
t.pack()
info = [['Ali',18],
['Zainab',16],
['Khalid',18]]
add_rows(t, ["Name", "Age"], info)
app.mainloop()
This now shows the text but, will still let me edit the text in side! :(
More information about the Python-list
mailing list