Faqts : Business : Programming : Shopping For You : Python : Tkinter

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

18 of 24 people (75%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

Is there a way to make a text box uneditable by the user, but insertable ( insert(END, 'schweet') ) by the application?

Oct 17th, 2009 06:16
adel85 adel85, Scott Mandarich, Greg Goodman, unknown unknown, richard_chamberlain


There may be a better way of doing it...

from Tkinter import *
root=Tk()
text=Text(root,width=50,height=50)
text.pack()
def intercept(event):
    return 'break'
text.bind('<Key>',intercept)
text.insert(END,'Sweet ;-)')
root.mainloop()

Here I bind a <Key> event to the intercept function - where I return 
'break' to stop the event propagating, so basically it's disabled. To 
undisable you'd just need to unbind that event.

---

You could create a disabled Text widget and bracket the programmatic
text insertion with calls to enable/disable the widget:

from Tkinter import *
root = Tk()
w = Text(root, width=50, height=5, state=DISABLED)
w.pack()

def do_insert():
	w.configure(state=NORMAL)
	w.insert(END, 'more text...')
	w.configure(state=DISABLED)

Button(root, text='insert', command=do_insert).pack()
root.mainloop()





http://www.borsaat.com/vb/f2/
http://www.borsaat.com/vb/f4/
http://www.borsaat.com/vb/f8/
http://www.borsaat.com/vb/f14/
http://www.borsaat.com/vb/f28/
http://www.borsaat.com/vb/f30/
http://www.borsaat.com/vb/f10/
http://www.borsaat.com/vb/f11/
http://www.borsaat.com/vb/f12/
http://www.borsaat.com/vb/f13/
http://www.borsaat.com/vb/f6/
http://www.borsaat.com/vb/f64/
http://www.borsaat.com/vb/f38/
http://www.borsaat.com/vb/f41/
http://www.borsaat.com/vb/f44/
http://www.borsaat.com/vb/f56/
http://www.borsaat.com/vb/f45/
http://www.borsaat.com/vb/f65/
http://www.borsaat.com/vb/f57/
http://www.borsaat.com/vb/f23/
http://www.borsaat.com/vb/f54/
http://www.borsaat.com/vb/f22/
http://www.borsaat.com/vb/f55/
http://www.borsaat.com/vb/f43/
http://www.borsaat.com/vb/f66/
http://www.borsaat.com/vb/f67/
http://www.borsaat.com/vb/f69/
http://www.borsaat.com/vb/f42/
http://www.borsaat.com/vb/f68/
http://www.borsaat.com/vb/f70/
http://www.borsaat.com/vb/f26/
http://www.borsaat.com/vb/
http://www.borsaat.com/vb/f90/





http://65.182.191.43/d/schools.html