Tkinter and wm geometry problem

Matthew Dixon Cowles matt at
Fri Sep 28 05:02:31 CEST 2001

On Thu, 27 Sep 2001 18:53:31 -0700, Brian Moyle <bmoyle at>

>I want to retain the last-known screen position of an application, so
>the next time it starts it appears at the same screen location.

>Unfortunately, I seem to be getting inconsistent results when using
>the geometry() methods in the Tk class, and I'm not sure how to
>obtain the desired results.

>Here's the output from a program I wrote that seems to demonstrate
>the problem:

>[bmoyle at bia tk_geometry_test]$ python
>Get: 150x100+304+320
>Set: 150x100+300+300
>Exit: 150x100+300+300
>[bmoyle at bia tk_geometry_test]$ python
>Get: 150x100+304+320
>Exit: 150x100+304+320
>[bmoyle at bia tk_geometry_test]$ 

That looks a lot like a window manager problem to me. Running your
code under GNOME (with RH 7.1 and Python 1.5.2) I get:

$ python 
Get: 150x100+300+300
Exit: 150x100+300+300
$ python 
Get: 150x100+300+300
Set: 150x100+300+300
Exit: 150x100+300+300

And the difference of 4 dots in the X direction and 20 in the Y
direction suggests that something is handling the space taken by the
window borders inconsistently. You could fudge things by assuming that
the inconsistency would be consistent as long as your app is running
under KDE (assuming that you can detect that somehow).

But my experience is that trying to second-guess window managers about
where to put your windows is no fun in the end. Some will cooperate
and some won't. And some that do cooperate will give ugly results.


More information about the Python-list mailing list