http://qs321.pair.com?node_id=11103751


in reply to Tk geometry unexpected return if window withdrawn and re-instated

Hi

Which version of Tk?

Get geometry when you bind to "<Configure>"?

I have observed that ->rootx and ->x change when you maximize/minimize the window

"764x480+50+50", 764, 480, 50, 50, 54, 73, "764x480+50+50", 764, 480, 50, 50, -32000, -32000, "1024x721+50+50", 1024, 721, -4, -4, 0, 19, "1024x721+50+50", 1024, 721, -4, -4, -32000, -32000,
  • Comment on Re: Tk geometry unexpected return if window withdrawn and re-instated
  • Download Code

Replies are listed 'Best First'.
Re^2: Tk geometry unexpected return if window withdrawn and re-instated
by WayneRas (Acolyte) on Aug 03, 2019 at 01:33 UTC

    Thank you for your time and response.
    The first line of my post provided the context including the Tk Version(Context - Ubuntu 18.04.2 LTS Gnome-Shell 3.28.3 Perl 5.26.1 Tk 804.034)
    I will experiment with results from <Configure> binding per your suggestion.
    If I may, what flavor of Unix and Desktop interface are you using, as it appears from the results you are not encountering the geometry issue I am?

      Hi

      If I may, what flavor of Unix and Desktop interface are you using, as it appears from the results you are not encountering the geometry issue I am?

      I'm using windows :) old osname=MSWin32, osvers=6.0, Tk 804.033

      What do you get from  $mw->winfo('geometry')?

        What do you get from $mw->winfo('geometry') ?
        With the code as posted replacing $mw->geometry with no parameters with $mw->winfo('geometry') and requesting $mw->geometry('+10+0') I got:
        init geometry=497x32+10+57,rootx=10,rooty=57;height:32.00
        exit geometry=497x32+10+57,rootx=10,rooty=57;height:32.00
        I have no doubt the nudge(+57) it got relates to the Ubuntu task bar at top of screen.
        I changed the requested geometry to '+100+150' to ensure well away from the edges/bars and got:
        init geometry=497x32+100+180,rootx=100,rooty=180;height:32.00
        exit geometry=497x32+100+180,rootx=100,rooty=180;height:32.00
        In this case the nudge is '+30'.
        The problem of course being/remaining is saving the window coordinates as returned via either $mw->geometry or $mw->winfo('geometry') and attempting to reuse them at start of the next app run means the window will basically be offset and this would be cumulative unless some adjustment made on my part - but that adjustment is unlikely to be one size fits all.
        Again thanks for your time and efforts. I however, believe the return on effort for providing that ability in my case is not worth it and the user will just have to move the window themselves each session - FYI undecorated windows, while not having this problem, have another which is if the user moves the window to cover the system task bar (which they cannot do with a decorated one), they cannot move it back if there is nothing to 'grab' i.e. the window fits within the task bar (so I don't let that happen).