More Tkinter Help please...

David LeBlanc whisper at oz.net
Fri Jun 14 05:50:22 CEST 2002


> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of SA
> Sent: Thursday, June 13, 2002 20:04
> To: python-list at python.org
> Subject: More Tkinter Help please...
>
>
> 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
>
> --
> http://mail.python.org/mailman/listinfo/python-list


Code comes up for me, but has other bugs I'm not able to diagnose.

FWIW, if you're trying to create a python shell, are you aware of PyCrust on
Sourceforge? If nothing else, you might get some pointers out of it :)

Dave LeBlanc
Seattle, WA USA






More information about the Python-list mailing list