how come .insert() don't work
Bennie
bennie at rotzjes.nl
Thu Oct 28 06:05:52 EDT 2004
Peter Otten wrote:
> 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
>
Thanks all,
Whit lambda its is working fine.
I want to make a methode that replaces the code:
def p(self):
self.tekst.insert(INSERT, "\t\t<p>\n\n\t\t</p>\n")
def pre(self):
self.tekst.insert(INSERT, "\t\t<pre>\n\n\t\t</pre>\n")
def br(self):
self.tekst.insert(INSERT, "<br />")
etc.
Now I have to type les :-)
Bye all! and many thanks ;)
Bennie,
More information about the Python-list
mailing list