请帮小弟我看看这个python运行的异常提示是什么意思呢?多谢
请帮我看看这个python运行的错误提示是什么意思呢?谢谢
这是错误提示?
------解决方案--------------------
少了图片,看看图片在不在,或者路径对不
------解决方案--------------------
invalid image非法的图片,打印下查看图片或路径。
- Python code
import wx class ToolbarFrame(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, id, '工具栏', size=(600, 300)) panel = wx.Panel(self) panel.SetBackgroundColour('Red') toolbar = self.CreateToolBar() #创建工具栏 toolbar.AddSimpleTool(wx.NewId(), wx.Image('ico/xin.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), "New") toolbar.AddSimpleTool(wx.NewId(), wx.Image('ico/xin.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), "Save") toolbar.AddSimpleTool(wx.ID_DELETE, wx.Image('ico/abc.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), "Delete") toolbar.AddSimpleTool(wx.ID_EXIT, wx.Image('ico/exit.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), "Exit") toolbar.SetToolBitmapSize(wx.Size(10, 10)) toolbar.Realize() #准备显示工具栏 statusbar = self.CreateStatusBar() #创建壮态栏 statusbar.SetStatusText("版权所有你这个王88") #给壮态栏添加信息 #绑定事件,用id来绑定事件 self.bind(wx.EVT_TOOL, self.OnExit, id=wx.ID_EXIT) self.bind(wx.EVT_TOOL, self.OnDelete, id= wx.ID_DELETE) def OnExit(self, event): dlg = wx.MessageDialog(None, '确定要退出程序吗?', '程序退出提示', wx.YES_NO | wx._ICON_QUESTION) result = dlg.ShowModal() #如果点击是按钮 if result == wx.ID_YES: self.Close(True) dlg.Destroy() def OnDelete(self, event): dlg = wx.MessageDialog(None, '你确定要删 除数据吗?', '删除数据提示', wx.YES_NO | wx.ICON_QUESTION) result = dlg.ShowModal() if result == wx.ID_YES: mydialog = MyDialog(parent = None, id = -1, title = '删队') dlg.Destroy() class MyDialog(wx.Dialog): def __init__(self, parent,id,title): wx.Dialog.__init__(self, parent, id, title, size=(200, 200)) self.panel = wx.Panel(self) #向对话框添加按钮 self.OkBtn = wx.Button(self, 10, '确定', pos=(50, 100), size=(80, 40)) #绑定事件 self.Bind(wx.EVT_TUTTON, self.CloseDlg, self.OkBtn) self.Show() def CloseDlg(self, event): self.Close() if __name__ == "__main__": app = wx.PySimpleApp() #实例化ToolbarFrame类 frame = ToolbarFrame(parent=None, id= -1) frame.Show() app.MainLoop()
这是错误提示?
- Python code
Traceback (most recent call last): File "F:/python/pyweb/wx_2.py", line 46, in <module> frame = ToolbarFrame(parent=None, id= -1) File "F:/python/pyweb/wx_2.py", line 8, in __init__ toolbar.AddSimpleTool(wx.NewId(), wx.Image('ico/xin.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), "New") File "F:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 3369, in ConvertToBitmap return _core_.Image_ConvertToBitmap(*args, **kwargs) PyAssertionError: C++ assertion "image.Ok()" failed at ..\..\src\msw\bitmap.cpp(802) in wxBitmap::CreateFromImage(): invalid image
------解决方案--------------------
少了图片,看看图片在不在,或者路径对不
------解决方案--------------------
invalid image非法的图片,打印下查看图片或路径。