[Tkinter-discuss] How to insert a string into a Text using Button

Bryan Oakley bryan.oakley at gmail.com
Fri Jun 1 23:19:34 CEST 2012


On Fri, Jun 1, 2012 at 3:50 PM, Alexander Matyukhin <
alex.matyukhin at yandex.ru> wrote:

> Hello to all! I have a simple code, which use tkinter.
> It has a Text widget and two Buttons. First Button
> must insert string into text. But it dont do it.
> The string is inserted into text after start and the
> button don't react on click.
> Second button must close window and it do it normal.
> Where did I have an error?
> <snip>
>
> # First button
> button_insert = tk.Button (main_window,
>      text='Insert string', command=InsertToText())
>

Remove the () for the command attribute. It should be:

    ... command=InsertToText)

The way you have it, you are calling InsertToText(), and the result of that
call (None) is what is getting assigned to the command attribute of the
button.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20120601/0b96c67f/attachment.html>


More information about the Tkinter-discuss mailing list