I’ve been having a heck of a time trying to get this to work.
I have an “ImagePanel” object (a subclass of wx.Panel) sitting inside a ScrolledPanel. The ImagePanel can be scaled up and down sometimes so I need the ScrolledPanel to update it’s scrollbars when this happens but I can’t figure out how to do it.
Of course the former didn’t work because paint is called when scrolling. I was trying to find a way to be sure the user wasn’t scrolling but came up dry. The latter didn’t work and I’m not sure why yet.
Any help would be greatly appreciated. I decided to use ScrolledPanel instead of ScrolledWindow because I was under the impression it could auto-update it’s scrollbars with it’s contents, but I’m starting to wonder if I should just use ScrolledWindow because it doesn’t require a sizer.
I've been having a heck of a time trying to get this to work.
I have an "ImagePanel" object (a subclass of wx.Panel) sitting inside a ScrolledPanel. The ImagePanel can be scaled up and down sometimes so I need the ScrolledPanel to update it's scrollbars when this happens but I can't figure out how to do it.
Of course the former didn't work because paint is called when scrolling. I was trying to find a way to be sure the user wasn't scrolling but came up dry. The latter didn't work and I'm not sure why yet.
The paint event is definitely not the right place to do this. Instead you should simply reset things when the image panel is scaled. For example, something like changing the size and min size of the image panel and then updating the virtual size of the scrolled window (or re-calling SetupScrolling if you stick with the scrolled panel) should do it.
Any help would be greatly appreciated. I decided to use ScrolledPanel instead of ScrolledWindow because I was under the impression it could auto-update it's scrollbars with it's contents, but I'm starting to wonder if I should just use ScrolledWindow because it doesn't require a sizer.
Probably. It will keep things a bit simpler. Also, if you have nothing besides the image panel in the scrolled window then you can just make your image panel class derive from wx.ScrolledWindow and deal with everything in the same class without needing the extra widget.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
On Wed, Dec 17, 2008 at 11:09 PM, Robin Dunn robin@alldunn.com wrote:
Adam Fraser wrote:
Hi all,
I’ve been having a heck of a time trying to get this to work.
I have an “ImagePanel” object (a subclass of wx.Panel) sitting inside a ScrolledPanel. The ImagePanel can be scaled up and down sometimes so I need the ScrolledPanel to update it’s scrollbars when this happens but I can’t figure out how to do it.
Of course the former didn’t work because paint is called when scrolling. I was trying to find a way to be sure the user wasn’t scrolling but came up dry. The latter didn’t work and I’m not sure why yet.
The paint event is definitely not the right place to do this. Instead you should simply reset things when the image panel is scaled. For example, something like changing the size and min size of the image panel and then updating the virtual size of the scrolled window (or re-calling SetupScrolling if you stick with the scrolled panel) should do it.
Any help would be greatly appreciated. I decided to use ScrolledPanel instead of ScrolledWindow because I was under the impression it could auto-update it’s scrollbars with it’s contents, but I’m starting to wonder if I should just use ScrolledWindow because it doesn’t require a sizer.
Probably. It will keep things a bit simpler. Also, if you have nothing besides the image panel in the scrolled window then you can just make your image panel class derive from wx.ScrolledWindow and deal with everything in the same class without needing the extra widget.