how come .insert() don't work

Peter Otten __peter__ at
Thu Oct 28 10:19:41 CEST 2004

Bennie wrote:

> self.html.add_command(label="p", command=self.tekst_in('p'))

Here you are setting the command parameter to the result of the
self.tekst_in() call which is always None. Change that to

self.html.add_command(label="p", command=self.insert_para)

and add a method to your App class that takes only the self parameter:

def insert_para(self):
That way insert_para() will be invoked when you click the menu command.
Alternately you can use lambda to the same effect:

self.html.add_command(label="p", command=lambda: self.tekst_in("p"))

but I think the approach outlined above is cleaner.


More information about the Python-list mailing list