一个简单的wxpython程序的错误急问!
例子中的一段小程序不能运行
import wx
import images
class ToolbarFrame(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, 'Toolbars',
size=(300, 200))
panel = wx.Panel(self)
panel.SetBackgroundColour('White')
statusBar = self.CreateStatusBar() #1 创建状态栏
toolbar = self.CreateToolBar() #2 创建工具栏
toolbar.AddSimpleTool(wx.NewId(), pydocview.images.getNewBitmap(),
"New", "Long help for 'New'") #3 给工具栏增加一个工具
toolbar.Realize() #4 准备显示工具栏
menuBar = wx.MenuBar() # 创建菜单栏
# 创建两个菜单
menu1 = wx.Menu()
menuBar.Append(menu1, " ")
menu2 = wx.Menu()
#6 创建菜单的项目
menu2.Append(wx.NewId(), " ", "Copy in status bar")
menu2.Append(wx.NewId(), "C ", "")
menu2.Append(wx.NewId(), "Paste", "")
menu2.AppendSeparator()
menu2.Append(wx.NewId(), " ", "Display Options")
menuBar.Append(menu2, " ") # 在菜单栏上附上菜单
self.SetMenuBar(menuBar) # 在框架上附上菜单栏
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = ToolbarFrame(parent=None, id=-1)
frame.Show()
app.MainLoop()
提示: ImportError: No module named images
将程序的
import images 改为from wx.lib import pydocview as images
提示
Traceback (most recent call last):
File "D:/ptest/menu.py", line 33, in <module>
frame = ToolbarFrame(parent=None, id=-1)
File "D:/ptest/menu.py", line 13, in __init__
toolbar.AddSimpleTool(wx.NewId(), pydocview.images.getNewBitmap(),
NameError: global name 'pydocview' is not defined
请大家帮帮忙,告诉我怎么解决,谢谢!