Can someone tell me why I am getting this error, when I run
the program below. I have the ThumbnailCtrl.py in the same
directory. If I comment out
t, b, s = getShadow()
self.shadow = wx.MemoryDC()
self.shadow.SelectObject(s)
and
if not thumb._alpha:
dc.Blit(imgRect.x+5, imgRect.y+5, imgRect.width, imgRect.height, self.shadow, 500-ww, 500-hh)
in ThumbnailCtrl.py, then it runs but no of course no shadow.
Thanks
Phil
Traceback (most recent call last):
File "E:\r09\py\tnc\ThumbnailSimple.py", line 35, in <module>
frame = ThumbnailSimple().Show()
File "E:\r09\py\tnc\ThumbnailSimple.py", line 10, in __init__
self.TC = TC.ThumbnailCtrl(self.panel, -1)
File "E:\r09\py\tnc\ThumbnailCtrl.py", line 556, in __init__
thumbfilter=thumbfilter)
File "E:\r09\py\tnc\ThumbnailCtrl.py", line 722, in __init__
t, b, s = getShadow()
File "E:\r09\py\tnc\ThumbnailCtrl.py", line 195, in getShadow
return (sh_tr, sh_bl, sh_sh.ConvertToBitmap())
File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 3336
, in ConvertToBitmap
return _core_.Image_ConvertToBitmap(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "image.Ok()" failed at ..\..\src\msw\bi
tmap.cpp(799) in wxBitmap::CreateFromImage(): invalid image
import wx
import os
import ThumbnailCtrl as TC
#-----------------------------------------------------Class ThumbnailSimple
class ThumbnailSimple(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, title='Thumbnail Simple')
self.panel = wx.Panel(self, -1)
self.TC = TC.ThumbnailCtrl(self.panel, -1)
self.dirbutton = wx.Button(self.panel, -1, "Select Image Directory")
# sizer -- Create, Add and Set
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.TC,1,wx.EXPAND,1)
sizer.Add(self.dirbutton, 0, wx.CENTER, 1)
self.panel.SetSizer(sizer)
sizer.Layout()
self.Bind(wx.EVT_BUTTON, self.OnSetDirectory, self.dirbutton)
self.TC.Bind(TC.EVT_THUMBNAILS_POINTED, self.OnPointed)
#-----------------------------------------------------------------Handlers
def OnSetDirectory(self, event):
dlg = wx.DirDialog(self, "Choose a directory with images:", defaultPath=os.getcwd())
if dlg.ShowModal() == wx.ID_OK:
self.TC.ShowDir(dlg.GetPath())
print("OnSetDirectory: directory changed to: %s\n"%dlg.GetPath())
dlg.Destroy()
def OnPointed(self, event):
print("OnPointed: Thumb pointed: %s\n"%self.TC.GetPointed())
event.Skip()
#-----------------------------------------------------------------MainLoop
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = ThumbnailSimple().Show()
app.MainLoop()