More Tkinter Help please...
Adonis
deltapigz at telocity.com
Thu Jun 13 23:45:34 EDT 2002
i ran the code, and i had no errors on loading it, you might want to try
placing all your functions above the __init__ call, i.e.:
class PyShell:
def expyth
...
def ...
def __init__
...
hope thie helps
Adonis
"SA" <sarmstrong13 at mac.com> wrote in message
news:B92EC762.70EC%sarmstrong13 at mac.com...
> Hi Everyone-
>
> I have another Tkinter question for you. I'm still trying to translate
> "that previously mentioned" Tcl/Tk program into Python/Tkinter. The
> following is all of the code I've managed so far:
>
> from Tkinter import *
> import sys
> import os
>
> class PyShell:
> def __init__(self, top):
>
> f = Frame(top)
> f.pack()
>
> self.t1 = Text(f, height="12", width="84", font="Courier 12")
> self.t1.pack(side=TOP, pady=2)
>
> self.t2 = Text(f, height="12", width="84", bg="lightblue",
> font="Courier 12")
> self.t2.pack(side=TOP, pady=2)
>
> self.b1 = Button(f, text="Execute", command=self.expyth)
> self.b1.pack(side=LEFT)
>
> self.b2 = Button(f, text="Clear Input", command=self.clearin)
> self.b2.pack(side=LEFT)
>
> self.b3 = Button(f, text="Clear Output", command=self.clearout)
> self.b3.pack(side=LEFT)
>
> self.b4 = Button(f, text="Save Input", command=self.savin)
> self.b4.pack(side=LEFT)
>
> def clearin(self):
> self.t1.delete(0,END)
>
> def clearout(self):
> self.t2.delete(0,END)
>
> def expyth(self):
> output = os.popen("python -c").t1()
> self.t2.delete(0,END)
> sys.stdout.write.t2(output)
>
> def savin(self):
> pass
>
> root = Tk()
>
> app = PyShell(root)
>
> root.mainloop()
>
> When I run this I get the following error:
>
> Traceback (most recent call last):
> File "PyShell.py", line 45, in ?
> app = PyShell(root)
> File "PyShell.py", line 17, in __init__
> self.b1 = Button(f, text="Execute", command=self.expyth)
> AttributeError: PyShell instance has no attribute 'expyth'
>
>
> Any ideas on what I'm doing wrong here?
>
> Thanks.
> SA
>
More information about the Python-list
mailing list