Re: [Tutor] A problem with a Tkinter program (using the text widget)

2005-02-05 Thread Alan Gauld
> Whats wrong here ?? :
> from Tkinter import *
> def p_text():
> print text.get()
> root=Tk()
> text=Text(root).pack()

pack() retirns None, YOu *must* use two steps:

text = Text()
text.pack()

> button=Button(root,text="Click here!!",command=p_text).pack()
> root.mainloop()
>
> I get an error that says that nontype object has no attribute
'get'...
> whats wrong ??

Because your text variable contains None, which doesn't support get...

Don't worry, its one of the most common Tkinter mistakes and
bites most folks at some stage...

Alan G.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] A problem with a Tkinter program (using the text widget)

2005-02-05 Thread Kent Johnson
Mark Kels wrote:
Hi all.
Whats wrong here ?? :
from Tkinter import *
def p_text():
print text.get()
root=Tk()
text=Text(root).pack()
pack() doesn't return a value. You have to do
text = Text(root)
text.pack()
I've been bitten by this one more than once myself :-(
Kent
button=Button(root,text="Click here!!",command=p_text).pack()
root.mainloop()
I get an error that says that nontype object has no attribute 'get'...
whats wrong ??
Thanks.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] A problem with a Tkinter program (using the text widget)

2005-02-05 Thread Mark Kels
Hi all.
Whats wrong here ?? :
from Tkinter import *
def p_text():
print text.get()
root=Tk()
text=Text(root).pack()
button=Button(root,text="Click here!!",command=p_text).pack()
root.mainloop()

I get an error that says that nontype object has no attribute 'get'...
whats wrong ??

Thanks.


-- 
1. The day Microsoft makes something that doesn't suck is probably the
day they start making vacuum cleaners.
2. Unix is user friendly - it's just picky about it's friends.
3. Documentation is like sex: when it is good, it is very, very good.
And when it is bad, it is better than nothing. - Dick Brandon
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor