Re: Problems running Tkinter in Linux

Mark Lutz (mlutz@KaPRE.COM)
Wed, 12 Apr 1995 15:22:26 +0700

> I have been trying to build python (version 1.2) on my 486
> running Linux (version 1.0-something). It compiled out of the
> box beautifully and passed the autotest, but when I try to run
> Tkinter (for example with the code below), it just hangs.
> Python stops responding to keyboard input, no button is ever
> created, the only way to stop it is to kill the process from
> another window.

> --------------------------------
> from Tkinter import *
> fred = Button()
>

Not sure this is your problem, but this isn't enough code to
put the button up. You also need to:

- use a geometry manager: 'pack' or 'place' it
- activate it: call its 'mainloop' method.

Either of the following should work:

> python
>>> from Tkinter import *
>>> fred = Button() # make the Button
>>> fred.pack() # place it on the default root
>>> fred.mainloop() # activate it, receive events,..

-or more consisely-

> python
>>> from Tkinter import *
>>> Button(None, {Pack:{}} ).mainloop() # configure when made

Of course, neither is very interesting (no callback action,
no button label, etc.). A more significant example--

> python
>>> from Tkinter import *
>>> Button(None, {'text':'Hello',
... 'command':'exit',
... Pack: {'side': 'left'}} ).mainloop()

Beyond this, the 'life-preserver' Tkinter manual does a good
job covering the API; there's a lot of defaults in the above.

Mark L.