From: Steven P. <n9...@n9...> - 2004-02-24 04:58:17
|
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. It doesn't save sash position for windows that have it, perhaps this is something that should be added as an optional parameter. Also, some windows (like config dialong, etc) would do better with a suggested size rather than suggested percentage, since it's not square in it's best form. Perhaps a separate percentage for height/width? Hmmmm.... It is doing a much better job on the Mac for sizing the print preview window, however I can't find a way to save any size changes made to the 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. I suppose in C++ you could override the destructor, but it doesn't exist in Python, does it? Any other ideas? I'm not coming up with much, so it's time to take a break and step back a little bit. |
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 |
From: Steven P. <n9...@n9...> - 2004-02-24 18:36:38
|
On Feb 23, 2004, at 11:47 PM, Roger Binns wrote: > 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 I thought to be smart, I should do that. You'll notice that if the window is offscreen, I allow for the fact that the user may *want* it offscreen, so I only move it on the edge so they can grab it. Some people way like them off to the side, who knows. ;-) Also, if it is set very large I set the size to about 90% of the screen resolution, but don't move it entirely on the screen. Since the size is scaled for them, if they do want to move it on the screen at least it will fit, but I'm not forcing it on them. What's the versionhistory stuff? {grin} OK, I put in some notes. >> 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?) OK, you've convinced me, I'll leave them alone. :-) I did start to look at it and you are right, MANY issues involved there and it's not as clear-cut as the size/position stuff.... >> 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. I've implemented a "aspect ratio" as a decimal value of width/height. I've made the first pass at resizing using the EVT_CLOSE stuff. It worked great for the print preview frame, but it doesn't seem to work for the dialogs like config or comm. When you hit the "OK", "CANCEL", etc... you don't end up ever receiving a close event, so for those I had to leave in the call to save settings for each case, and I added a OnClose event for the case where the user just clicks on the window-close button; I treat it like a Cancel button. This isn't as generic as your proposed suggestion, but that generic approach wouldn't work with dialogs anyway from what I've seen. I'll look at implementing it for windows that it *would* work for, dialogs would just need a little extra code to cover all the bases. I'll keep poking at it, but as it is it's functional for the main window, print preview window, config dialog and commbrowser dialog. It's a start, and I can always clean up and refine later. ;-) |