From: Roger B. <ro...@ro...> - 2004-02-24 05:47:30
|
Steven Palm wrote: > I've started to implement some of the window size/position saving code. > Roger, check it out and let me know if this is what you had in mind. Looks good. It is what I was expecting, and you even check the window is on the screen :-) Don't forget to update help/versionhistory.htd > It > doesn't save sash position for windows that have it, perhaps this is > something that should be added as an optional parameter. Sashes matter less and have far more sizing issues. (Which side are you sizing from, and what do you shrink if the overall window is too large?) > Perhaps a separate percentage for height/width? Hmmmm.... Maybe just a percentage of screen and aspect ratio instead? I think the aspect ratio better defines if the window looks well proportioned. > window by the user... The print preview thing goes off on it's own when > you do the show() method, and I can't find a hook to determine what the > last size/position was before it was closed. There are two ways of doing it. One is make it modal. The other simpler way is to hook into EVT_CLOSE. In particular note that EVT_CLOSE doesn't require the handler to be in the same class. My best guess is that the following should work in gui.py: def RegisterForSaveSize(self, window, prefix): wx.EVT_CLOSE(window, lambda evt: self.SaveSizeInfo(window, prefix, evt)) def SaveSizeInfo(self, window, prefix, evt): evt.Skip() # cause remaining event handlers to run ... save dimensions of window, using config key prefix You could even combine the RegisterForSaveSize to resize the supplied window based on the config (ie add in the percentage/aspect ratio params). I am not 100% certain the above will work, but if it does it should make it trivial to do sizing for all windows just by calling Register... from their constructor. Roger |