how come .insert() don't work
Bennie
bennie at rotzjes.nl
Thu Oct 28 03:36:25 EDT 2004
Hi,
This is a chunck out of my program:
--------------------------------------------------
from Tkinter import *
class App:
def __init__(self, master):
frame = Frame(master)
frame.pack()
self.menubar = Menu(root)
self.html = Menu(self.menubar, tearoff=0)
self.html.add_command(label="p", command=self.tekst_in('p'))
# self.html.add_command(label="p", command=self.tekst_a)
self.menubar.add_cascade(label="html", menu=self.html)
root.config(menu=self.menubar)
self.tekst = Text()
self.tekst.pack(fill=BOTH, expand=YES)
def tekst_in(self, tag):
tekst_tag={'p': '\t\t<p>\n\n\t\t</p>\n', 'br': '<br />'}
self.tekst.insert(INSERT, tekst_tag[tag])
# This works
#def tekst_a(self):
# self.tekst.insert(INSERT, "<p> </p>")
if __name__ == '__main__':
root = Tk()
app = App(root)
root.mainloop()
--------------------------------------------------
The error is:
-------------------------------
Traceback (most recent call last):
File "test.py", line 30, in ?
app = App(root)
File "test.py", line 10, in __init__
self.html.add_command(label="p", command=self.tekst_in('p'))
File "test.py", line 21, in tekst_in
self.tekst.insert(INSERT, tekst_tag[tag])
AttributeError: App instance has no attribute 'tekst'
------------------------------------------------------
hope this is enough info.
More information about the Python-list
mailing list