This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: TKinter.Tk.geometry(Tk.winfo_geometry()) should be idempotent
Type: behavior Stage: resolved
Components: Tkinter Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Ben Li-Sauerwine, epaine, gpolo, serhiy.storchaka
Priority: normal Keywords:

Created on 2020-06-10 20:04 by Ben Li-Sauerwine, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tkinter_ex.py Ben Li-Sauerwine, 2020-06-10 20:04 Example which reproduces the issue.
Messages (4)
msg371236 - (view) Author: Ben Li-Sauerwine (Ben Li-Sauerwine) Date: 2020-06-10 20:04
One would expect that calling TKinter.Tk.geometry(tk.winfo_geometry()) would be idempotent.  However, based on the system window frame, it is not and doing so moves the window down the screen.

Running the example below reproduces the issue.
msg371309 - (view) Author: E. Paine (epaine) * Date: 2020-06-11 16:43
This is interesting as it works fine on Windows but does the behaviour you describe on Linux. I presume the difference is due to how Tcl/Tk handles the title-bar, in which case this isn't really a tkinter issue and there isn't much that can be done (from a tkinter perspective anyway).

When tested (on Linux), however, calling tk.geometry() returned a different value to tk.winfo_geometry(). Calling tk.geometry(tk.geometry()) did not change the window position and everything worked as expected (weird!).

I am not sure, though, if this behaviour should be changed. Looking at the Tk man page (https://www.tcl.tk/man/tcl8.6/TkCmd/wm.htm#M42), it says:
"Note that this is related to winfo geometry, but not the same. That [...] always reflects Tk's current understanding of the actual size and location of window, whereas wm geometry allows [...] querying of the window manager's understanding of the size and location of the window. This can vary significantly, for example to reflect the addition of decorative elements to window such as title bars, and window managers are not required to precisely follow the requests made through this command."
msg371383 - (view) Author: Ben Li-Sauerwine (Ben Li-Sauerwine) Date: 2020-06-12 15:22
Thanks for clarifying.  Using Tk.geometry() instead of Tk.winfo_geometry() does indeed resolve the issue on Linux.

Weird that using Tk.winfo_geometry() is idempotent under Windows, though.
msg371505 - (view) Author: E. Paine (epaine) * Date: 2020-06-14 14:40
I am glad I was able to help.

To be consistent with Tk, I don't think the tkinter behaviour should be changed. If you agree, I would really appreciate if you could close the issue as "not a bug" (to give the core devs one less issue they need to look through!).
History
Date User Action Args
2022-04-11 14:59:32adminsetgithub: 85117
2020-06-14 15:09:38serhiy.storchakasetstatus: open -> closed
resolution: not a bug
stage: resolved
2020-06-14 14:40:23epainesetmessages: + msg371505
2020-06-12 15:22:19Ben Li-Sauerwinesetmessages: + msg371383
2020-06-11 16:43:17epainesetnosy: + gpolo, serhiy.storchaka, epaine
messages: + msg371309
2020-06-10 20:04:18Ben Li-Sauerwinesettype: behavior
2020-06-10 20:04:10Ben Li-Sauerwinecreate