[Tutor] More Tkinter Help Please

alan.gauld@bt.com alan.gauld@bt.com
Fri, 14 Jun 2002 17:46:35 +0100


> class PyShell:
>     def __init__(self, top):
>         self.b1 = Button(f, text="Execute", command=self.expyth)
>         self.b1.pack(side=LEFT)
>
>     def expyth(self):
>         output = os.popen("python -c").t1()
>         self.t2.delete(0,END)
>         sys.stdout.write.t2(output)

> When I run this I get the following error:
> 
> Traceback (most recent call last):
> AttributeError: PyShell instance has no attribute 'expyth'

I think its because at the time that init is defined 
it can't see self.expyth because its not been defined yet. 
Try moving the init method after all the other methods?

However I'm not really happy with that answer because init 
shouldn't run till you  create an instance which is after 
you define the class, so I could very well be wrong!

Alan G.