Discussion:
Top level wxFrame position changed after restart
Martin Manns
2014-09-28 20:30:52 UTC
Permalink
Hi

I am trying to get the main window of my application into the same
position as it was before I closed the application.

Therefore, I get the position from
position = self.main_window.GetScreenPositionTuple()
and save it to a file.

When restarting, I read the file and set the position
self.SetPosition(position)

However, the position is off:
Position before exit: (351, 170)
Position after restart: (350, 141)

The difference looks similar to the border size to me.
I have attached a small example.

How do I set the Window position without such an offset?

My configuration:

Debian testing
Python 2.7.8
wxPython 3.0.1.1 gtk2 (classic)
Window manager E17 0.17.6

A user has reported a similar effect on Windows 8.


Martin
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Michael Moriarity
2014-09-28 21:23:05 UTC
Permalink
I do this in almost all my apps, and it works fine. The only difference I
can see is that I save the coordinates in a sqlite database file, rather
than ast (which I know nothing about). It seems clear from your code that
the coordinates you are saving using ast are not being returned accurately.
The problem is probably there, not in wxPython.
Post by Martin Manns
Hi
I am trying to get the main window of my application into the same
position as it was before I closed the application.
Therefore, I get the position from
position = self.main_window.GetScreenPositionTuple()
and save it to a file.
When restarting, I read the file and set the position
self.SetPosition(position)
Position before exit: (351, 170)
Position after restart: (350, 141)
The difference looks similar to the border size to me.
I have attached a small example.
How do I set the Window position without such an offset?
Debian testing
Python 2.7.8
wxPython 3.0.1.1 gtk2 (classic)
Window manager E17 0.17.6
A user has reported a similar effect on Windows 8.
Martin
--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
Best Regards,
Michael Moriarity
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Martin Manns
2014-09-28 22:29:17 UTC
Permalink
On Sun, 28 Sep 2014 17:23:05 -0400
Post by Michael Moriarity
I do this in almost all my apps, and it works fine. The only
difference I can see is that I save the coordinates in a sqlite
database file, rather than ast (which I know nothing about). It seems
clear from your code that the coordinates you are saving using ast
are not being returned accurately. The problem is probably there, not
in wxPython.
The coordinates definitely remain the same when stored, i.e. both
positions in the example differ when the window is not moved.

I just noticed that on another Debian box with KDE instead of E17, this
does not occur.

Martin
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Michael Moriarity
2014-09-29 03:33:15 UTC
Permalink
Post by Martin Manns
On Sun, 28 Sep 2014 17:23:05 -0400
Post by Michael Moriarity
I do this in almost all my apps, and it works fine. The only
difference I can see is that I save the coordinates in a sqlite
database file, rather than ast (which I know nothing about). It seems
clear from your code that the coordinates you are saving using ast
are not being returned accurately. The problem is probably there, not
in wxPython.
The coordinates definitely remain the same when stored, i.e. both
positions in the example differ when the window is not moved.
I just noticed that on another Debian box with KDE instead of E17, this
does not occur.
Martin
What I mean is, I can't run your test app, because I don't have ast
installed. However, in your code you print out the coordinates just before
you save them, and just after you restore them. In your original post, you
show these numbers as being different. If that is the case, then what you
are getting back seems to not be the same as what you are saving, but
perhaps I have misunderstood. Of course, if this differs from one Linux
desktop to another, you would naturally suspect the window manager.
--
Best Regards,
Michael Moriarity
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Michael Moriarity
2014-09-29 03:43:54 UTC
Permalink
Oops, I just realized that ast is a standard module. I hadn't heard of it
before. I have just run your example code, and I can confirm that on
Xubuntu 12.04 it works as expected. Looks like the WM is the problem.
--
Best Regards,
Michael Moriarity
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Nathan McCorkle
2014-09-29 05:57:50 UTC
Permalink
Post by Martin Manns
Debian testing
Python 2.7.8
wxPython 3.0.1.1 gtk2 (classic)
Window manager E17 0.17.6
I can test on Win 7 and XP tomorrow, but right now on Ubuntu 14.04
with 3.0.1.1 gtk2 (classic) that I compiled last week, your program seems
to work fine.
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Werner
2014-09-29 07:24:06 UTC
Permalink
Hi,
Post by Martin Manns
Hi
I am trying to get the main window of my application into the same
position as it was before I closed the application.
Therefore, I get the position from
position = self.main_window.GetScreenPositionTuple()
and save it to a file.
When restarting, I read the file and set the position
self.SetPosition(position)
Position before exit: (351, 170)
Position after restart: (350, 141)
The difference looks similar to the border size to me.
I have attached a small example.
How do I set the Window position without such an offset?
Debian testing
Python 2.7.8
wxPython 3.0.1.1 gtk2 (classic)
Window manager E17 0.17.6
A user has reported a similar effect on Windows 8.
Hhm, I am on Windows 8 with Python 2.7.8 and wxPython 3.0.1.1 and your
the position on close is used on restart, so works as expected.

If you persist more then the position you might want to link into
wx.lib.agw.persist.

Werner
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Nathan McCorkle
2014-09-29 08:50:35 UTC
Permalink
Post by Werner
Hhm, I am on Windows 8 with Python 2.7.8 and wxPython 3.0.1.1 and your
the position on close is used on restart, so works as expected.
If you persist more then the position you might want to link into
wx.lib.agw.persist.
You might also try the functions with 'client' in the name... for example
this is how I am getting the screen size that is available after
considering the Window manager navigation bars:
topBarHeight, sideBarWidth, widthAvailable, heightAvailable =
wx.ClientDisplayRect()
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Martin Manns
2014-09-29 20:36:33 UTC
Permalink
On Mon, 29 Sep 2014 01:50:35 -0700 (PDT)
Post by Nathan McCorkle
Post by Werner
If you persist more then the position you might want to link into
wx.lib.agw.persist.
I will try this out.
Post by Nathan McCorkle
You might also try the functions with 'client' in the name... for
example this is how I am getting the screen size that is available
topBarHeight, sideBarWidth, widthAvailable, heightAvailable =
wx.ClientDisplayRect()
GetClientAreaOrigin() returns (0, 0) even though there are window
decorations.

Martin
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Martin Manns
2014-09-29 23:10:21 UTC
Permalink
On Mon, 29 Sep 2014 01:50:35 -0700 (PDT)
Post by Werner
If you persist more then the position you might want to link into
wx.lib.agw.persist.
Same effect with the agw persistence manager.
I have attached my test code.

Should I file a bug report?

Martin
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Nathan McCorkle
2014-09-29 23:17:30 UTC
Permalink
Post by Martin Manns
On Mon, 29 Sep 2014 01:50:35 -0700 (PDT)
Post by Werner
If you persist more then the position you might want to link into
wx.lib.agw.persist.
Same effect with the agw persistence manager.
I have attached my test code.
Should I file a bug report?
Not for persist, that just handles the loading and saving of data when you
open or close your app.


You might try self.ClientToScreen((0,0))

See my modifications, when the frame is moved, stuff prints out.
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Martin Manns
2014-09-30 19:20:37 UTC
Permalink
On Mon, 29 Sep 2014 16:17:30 -0700 (PDT)
Post by Nathan McCorkle
You might try self.ClientToScreen((0,0))
See my modifications, when the frame is moved, stuff prints out.
Here is the printout (prints out when moving the mouse over the window)


xxx:~/tmp$ python testRemeberPos.py
(765, 576)
(0, 0, 1280, 1024)
(1280, 1024)
(0, 0)
(300, 200)
(764, 547)
(765, 576)

(0, 0, 1280, 1024)
(1280, 1024)
(0, 0)
(300, 200)
(764, 547)
(765, 576)

(0, 0, 1280, 1024)
(1280, 1024)
(0, 0)
(300, 200)
(764, 547)
(765, 576)

(0, 0, 1280, 1024)
(1280, 1024)
(0, 0)
(300, 200)
(764, 547)
(765, 576)

(0, 0, 1280, 1024)
(1280, 1024)
(0, 0)
(300, 200)
(764, 547)
(765, 576)

(764, 547)
xxx:~/tmp$
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Nathan McCorkle
2014-09-30 23:27:41 UTC
Permalink
So that fixes it then, right? The difference between the
ClientToScreen(0,0) and GetScreenPositionTuple() is the same as the
difference in your first post... i.e. (1, 29)

Originally you posted:
Position before exit: (351, 170)
Position after restart: (350, 141)

last two rows of printout blocks:
(764, 547)
(765, 576)


diff first:
(1, 29)

diff second:
(1, 29)
Post by Martin Manns
On Mon, 29 Sep 2014 16:17:30 -0700 (PDT)
Post by Nathan McCorkle
You might try self.ClientToScreen((0,0))
See my modifications, when the frame is moved, stuff prints out.
Here is the printout (prints out when moving the mouse over the window)
xxx:~/tmp$ python testRemeberPos.py
(765, 576)
(0, 0, 1280, 1024)
(1280, 1024)
(0, 0)
(300, 200)
(764, 547)
(765, 576)
(0, 0, 1280, 1024)
(1280, 1024)
(0, 0)
(300, 200)
(764, 547)
(765, 576)
(0, 0, 1280, 1024)
(1280, 1024)
(0, 0)
(300, 200)
(764, 547)
(765, 576)
(0, 0, 1280, 1024)
(1280, 1024)
(0, 0)
(300, 200)
(764, 547)
(765, 576)
(0, 0, 1280, 1024)
(1280, 1024)
(0, 0)
(300, 200)
(764, 547)
(765, 576)
(764, 547)
xxx:~/tmp$
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Martin Manns
2014-10-02 22:29:50 UTC
Permalink
On Tue, 30 Sep 2014 16:27:41 -0700 (PDT)
Post by Nathan McCorkle
So that fixes it then, right? The difference between the
ClientToScreen(0,0) and GetScreenPositionTuple() is the same as the
difference in your first post... i.e. (1, 29)
Position before exit: (351, 170)
Position after restart: (350, 141)
(764, 547)
(765, 576)
(1, 29)
(1, 29)
Seems like it.
However now, I have to test all platforms and Window managers.

Thank you for your help.

Martin
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Nathan McCorkle
2014-10-02 23:15:27 UTC
Permalink
Post by Martin Manns
Seems like it.
However now, I have to test all platforms and Window managers.
Thank you for your help.
Martin
Please let us know if it works on the platforms you're testing for!

All the best,
-Nathan
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Martin Manns
2014-10-07 23:06:16 UTC
Permalink
On Thu, 2 Oct 2014 16:15:27 -0700 (PDT)
Post by Nathan McCorkle
Please let us know if it works on the platforms you're testing for!
No luck on Windows 8.1. The window still shifts there.

The user claims to have the following configuration:

Windows 8.1, wxPython 3.0.1.1 for py27 32bit, Python 2.7.6.

Two monitor main-1920×1080 & second-1280×1024


Regards

Martin
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Robin Dunn
2014-10-07 07:01:03 UTC
Permalink
Post by Martin Manns
Hi
I am trying to get the main window of my application into the same
position as it was before I closed the application.
Therefore, I get the position from
position = self.main_window.GetScreenPositionTuple()
and save it to a file.
When restarting, I read the file and set the position
self.SetPosition(position)
Position before exit: (351, 170)
Position after restart: (350, 141)
The difference looks similar to the border size to me.
I have attached a small example.
How do I set the Window position without such an offset?
Debian testing
Python 2.7.8
wxPython 3.0.1.1 gtk2 (classic)
Window manager E17 0.17.6
A user has reported a similar effect on Windows 8.
IIRC there was a change in the 2.9 series that had to do with frame
positions and sizes on GTK. Originally since there isn't a standard way
to get frame sizes on X that works in all environments and window
managers then it was pretty much just ignored and the size of the client
area was used instead. Since then there is a common way to deal with
sizes of window decorations which has gained traction and so wx is now
trying to use that, if I understand correctly.

That should help things like this to work more consistently (compared
with the other platforms) on GTK than before, but probably not in all
situations. One way around for sizes as others have mentioned is to
save and set the client size of the frame instead of the frame's size.
For positions it might be a little more tricky, but using things like
ClientToScreen and ScreenToClient will be helpful there.
--
Robin Dunn
Software Craftsman
http://wxPython.org
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...