How do you do this in python with tk?
Fredrik Lundh
fredrik at pythonware.com
Wed Oct 13 17:19:59 EDT 2004
"Ali" wrote:
>> 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! :(
when the state is set to normal, you can insert text into the widget, and
so can the user. when the state is set to disabled, you cannot insert text,
and neither can the user.
now try setting the state to disabled *after* you've inserted the text.
</F>
More information about the Python-list
mailing list