[wxPython-users] EVT_MOVE: bug? (event contains wrong position)

Josiah Carlson jcarlson at uci.edu
Sat Jul 1 22:57:10 PDT 2006


Aliaksei Hayeu <alex_de_guy at tut.by> wrote:
> >>>   self is wx.Frame descendant. I've yet to see the need to override
> >>> OnSize method in any other controls, sizers do the nice job. :) And I
> >>> bind EVT_SIZE and EVT_MOVE in my frame only because I want to track the
> >>> window size and position to write it to config file on app exit, so
> >>> that it can be restored on next app start.
> >>
> >> You can do that in an EVT_CLOSE handler.
> 
>   I wish I could! Unfortunately, it's not so simple. For example,
> there's no reason to save maximized window position/size - I need to
> save coords _before_ window got maximized. And window position if it's
> minimized (or iconized in wxPython terms) is (-32000,-32000) - what use
> are these values?
>   Another thing. Let's say, I have a normal frame. Then I maximize it,
> and IsMaximized() returns True. So far so good. But then I minimize
> this frame. IsIconized() returns True, again, as expected, but IsMaximized()
> now returns False. If I quit now and save the current state, next time I
> start the application I'll expect the window to be maximized after
> restoring, and it won't be.
>   So, I manually store real window position and maximized state in the
> EVT_SIZE and EVT_MOVE handlers and everything works fine.

Use a wx.Timer to post an event every few seconds.  Use win.GetSize() . 
Pay attention to EVT_MAXIMIZED and EVT_ICONIZED events, to determine
whether you should be performing win.GetSize(), and/or starting/stopping
the timer.

 - Josiah





More information about the wxpython-users mailing list