i wrote program in python can download pictures web. every downloaded picture doing preview of picture in gui every time receive following error:
traceback (most recent call last): file "/usr/lib/python2.7/site-packages/wx-2.8-gtk2-unicode/wx/_core.py", line 14665, in <lambda> lambda event: event.callable(*event.args, **event.kw) ) typeerror: 'nonetype' object not callable traceback (most recent call last): file "/usr/lib/python2.7/site-packages/wx-2.8-gtk2-unicode/wx/_core.py", line 14665, in <lambda> lambda event: event.callable(*event.args, **event.kw) ) typeerror: 'nonetype' object not callable traceback (most recent call last): file "/usr/lib/python2.7/site-packages/wx-2.8-gtk2-unicode/wx/_core.py", line 14665, in <lambda> lambda event: event.callable(*event.args, **event.kw) ) typeerror: 'nonetype' object not callable traceback (most recent call last): file "/usr/lib/python2.7/site-packages/wx-2.8-gtk2-unicode/wx/_core.py", line 14665, in <lambda> lambda event: event.callable(*event.args, **event.kw) ) typeerror: 'nonetype' object not callable funny thing: still works. error mean? , how can fix it?
the code causing error should line:
wx.callafter(self.image.setbitmap, wx.bitmapfromimage(wx.image(imagepath, wx.bitmap_type_any).rescale(width, height)))
i couldn't reproduce problem following code:
#!/usr/bin/env python import wx class frame(wx.frame): def __init__(self): wx.frame.__init__(self, none, title="title") panel = wx.panel(self) box = wx.boxsizer(wx.vertical) button = wx.button(panel, wx.id_any, "load image") button.bind(wx.evt_button, self.changeimage) box.add(button, 0, wx.all, 10) self.image = wx.staticbitmap(panel) box.add(self.image, 0, wx.all, 10) panel.setsizer(box) panel.layout() def changeimage(self, event): wx.callafter(self.image.setbitmap, wx.bitmapfromimage(wx.image("modernart.png", wx.bitmap_type_any).rescale(150, 150))) if __name__ == "__main__": app = wx.app() top = frame() top.show() app.mainloop() (you need modernart.png image in same folder. i'll leave create it.)
if replaced self.image.setbitmap in call wx.callafter none, able reproduce error.
are calling wx.callafter somewhere other line you've shown above?
Comments
Post a Comment