PRobbins wrote:
Ok, changing it to a static bitmap
seemed to work partially. Now I’m running into a problem where
only a small sliver of the image is displayed and there is no
vertical scrollbar(see attached image). Here is my scrollPanel
class code and the Main Frame’s sizer code. I’ve tried changing
the SetSizerAndFit to SetSizer so that doesn’t seem to be the
problem.
I hope you do not mind if I make some stylistic comments. It's a
bad habit of mine.
class iBrowserImagePanel(wx.ScrolledWindow):
def __init__(self, parent):
wx.ScrolledWindow.__init__(self, parent)
self.parent = parent
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.bmp = wx.StaticBitmap(self, -1,
wx.EmptyBitmap(500,500))
self.sizer.Add(self.bmp)
self.SetSizer(self.sizer)
If the bitmap is the only thing in the scrolled window, you
shouldn’t need a sizer here at all.
try:
self.currentImage = Workspace.data.getImageDirectory()
How can that first line fail? In any case, if it DOES fail, this
will leave self.currentImage unchanged. It won’t set
self.currentImage to match ImageIndex 1.
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)
In a gross overgeneralization, any time you compare with ==True and
==False, it’s a problem. It’s better to think in terms of “true
values” and “false” values. Further, it’s more efficient to use
if/else than it is to do “if == True” and “if == False”. For
example:
if enhanceTool.norm.GetValue():
self.img.normalize('RGB')
else:
self.img.normalize(None)
if enhanceTool.eq.GetValue():
self.img.equalize('RGB')
else:
self.img.equalize(None)
Or, preferable to some:
self.img.normalize( 'RGB' if enhanceTool.norm.GetValue() else
None )
self.img.equalize( 'RGB' if enhanceTool.eq.GetValue() else None
)
and the last one can be a single expression:
self.img.invert( enhanceTool.invert.GetValue() )
···
-- Tim Roberts, Providenza & Boekelheide, Inc.
timr@probo.com