I am trying to put an image in a Scrolled Window. I have placed the
scrolled window on a separate panel, along with some widgets. The
scroll bars never appear and the image is cut off on the right and
bottom. Unfortunately, my employer won't let me post the entire code
or upload and sample application. I have provided a screenshot of the
problem. Im using windows XP and wxPython version 2.8.
**********************************************************************************
Code that replaces the empty bitmap in scrollSizer with an actual
image
***********************************************************************************
def loadCurrentImage(self):
'''
Loads the current image based off Workspace.currentImageIndex.
This function is called after every image change.
'''
try:
self.currentImage = Workspace.data.getImageDirectory() +
os.sep + Workspace.data.getImageName(Workspace.currentImageIndex)
except:
Workspace.currentImageIndex = 1
self.img = simple_image.Image()
if enhanceTool.norm.GetValue()==True:
self.img.normalize('RGB')
if enhanceTool.norm.GetValue()==False:
self.img.normalize(None)
if enhanceTool.eq.GetValue()==True:
self.img.equalize('RGB')
if enhanceTool.eq.GetValue()==False:
self.img.equalize(None)
if enhanceTool.sharp.GetValue()==True:
self.img.enhanceSharpness(2.0)
if enhanceTool.sharp.GetValue()==False:
self.img.enhanceSharpness(1.0)
if enhanceTool.invert.GetValue()==True:
self.img.invert(True)
if enhanceTool.invert.GetValue()==False:
self.img.invert(False)
self.img.load(self.currentImage)
imageBrowser.iWidth = self.img.wx().GetWidth()
imageBrowser.iHeight = self.img.wx().GetHeight()
self.img =
self.img.wx().Scale(imageBrowser.iWidth*Workspace.zoomScale,
imageBrowser.iHeight*Workspace.zoomScale).ConvertToBitmap()
self.scrollSizer.Remove(0)
self.scrollSizer.Prepend(self.img.GetSize())
self.Refresh()
self.Fit()
I am trying to put an image in a Scrolled Window. I have placed the
scrolled window on a separate panel, along with some widgets. The
scroll bars never appear and the image is cut off on the right and
bottom.
Do you ever call SetVirtualSize and SetScrollRate to tell the scrolled window how big its scrollable area should be and how much pixels each step from the scollbars will scroll the content?
Unfortunately, my employer won't let me post the entire code
or upload and sample application.
Sounds like your boss needs some OSS "reeducation" (got a clue-bat handy? )
1.)Ok, here is some sample code that has the same problem I am running
into. I suspect if I can figure this out I can figure the problem out
in the larger application. The scroll bars are simply not
appearing.
2.)Is calling SetScrollBars the same as calling SetVirtualSize and
SetScrollRate? The parameters look the same to me in the wx online
docs.
3.)Also, could someone tell me how to add an image to my post? I feel
really dumb...\:
On May 4, 12:49 pm, Robin Dunn <ro...@alldunn.com> wrote:
On 5/4/11 8:57 AM, PRobbins wrote:
> I am trying to put an image in a Scrolled Window. I have placed the
> scrolled window on a separate panel, along with some widgets. The
> scroll bars never appear and the image is cut off on the right and
> bottom.
Do you ever call SetVirtualSize and SetScrollRate to tell the scrolled
window how big its scrollable area should be and how much pixels each
step from the scollbars will scroll the content?
> Unfortunately, my employer won't let me post the entire code
> or upload and sample application.
Sounds like your boss needs some OSS "reeducation" (got a clue-bat
handy? )
--
Robin Dunn
Software Craftsmanhttp://wxPython.org
I am trying to put an image in a Scrolled Window. I have placed the
scrolled window on a separate panel, along with some widgets. The
scroll bars never appear and the image is cut off on the right and
bottom.
Do you ever call SetVirtualSize and SetScrollRate to tell the scrolled
window how big its scrollable area should be and how much pixels each
step from the scollbars will scroll the content?
Unfortunately, my employer won't let me post the entire code
or upload and sample application.
Sounds like your boss needs some OSS "reeducation" (got a clue-bat
handy? )
1.)Ok, here is some sample code that has the same problem I am running
into. I suspect if I can figure this out I can figure the problem out
in the larger application. The scroll bars are simply not
appearing.
See attached. You left out SetScrollRate. I also removed the extra panel and sizers as they are not needed for this example. If you do need the extra panel in your app (for including other controls in the same area for example) then be sure you get the nesting correct and don't use SetSizerAndFit as it will also set the min size based on the content and since you're expecting the bitmap to be larger than the window that will cause problems (like the panel or scrolled window overflowing the visual area and the scrollbars not being visible because they are clipped by the frame.)
2.)Is calling SetScrollBars the same as calling SetVirtualSize and
SetScrollRate? The parameters look the same to me in the wx online
docs.
Yes, more or less. But using SetVirtualSize and SetScrollRate are the preferred way to do it these days.
3.)Also, could someone tell me how to add an image to my post? I feel
really dumb...\:
By using regular email instead of the browser interface and attaching the files to the message like normal. See #7 at MakingSampleApps - wxPyWiki