[Tutor] help with .get in Tkinter

Alan Gauld alan.gauld at freenet.co.uk
Sun Feb 20 19:09:06 CET 2005


There are two problems here:

> from Tkinter import *
> def go():...

> e=Entry(main)
> e.pack()

This is OK but...

> b=Button(main,text='OK',command=go()).pack()

Problem 1:
This will store None in b because pack() always returns None.

Problem 2:
> For some reason the function is called before I click the button,
> I get .10037088 before I have done a thing.

Thats because you are calling go() inside the widget specification,
you need to pass a reference to the function instead - ie miss out
the parens:


That should fix it.

Alan G
Author of the Learn to Program web tutor

More information about the Tutor mailing list