how come .insert() don't work

Peter Otten __peter__ at web.de
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):
    self.tekst_in("p")
 
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.

Peter   








More information about the Python-list mailing list