wxPython AttributeError:模块没有属性“框架" [英] wxPython AttributeError: module has no attribute 'Frame'

查看:37
本文介绍了wxPython AttributeError:模块没有属性“框架"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试学习 wxPython,当我按照教程学习时.我遇到了一些错误.我做了很多研究,在这个网站上找不到任何与我的情况有关的东西,我也重新安装并尝试了所有不同版本的 wxpython for python 2.7 仍然没有区别.我使用的是 64 位戴尔 Windows 8 计算机.这是教程中的代码:

I'm trying to learn wxPython and when I'm following the tutorial to learn it. I'm encountering some errors. I have done a bunch of research and can't find anything on this site that relates to my situation and I've also re installed and tried all the different versions of wxpython for python 2.7 there is still no difference. I'm on a Dell Windows 8 computer 64-bit. Here is the code from the tutorial:

import wx
class MyFrame(wx.Frame):

    def __init__(self, parent, title):
          wx.Frame.__init__(self, parent, title=title, size=(200,100))
          self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)
          self.Show(True)

app = wx.App(False)
frame = MyFrame(None, 'Small editor')
app.MainLoop()

和错误:

Traceback (most recent call last):
    File "C:\Python27\test", line 2, in <module>
         class MyFrame(wx.Frame):
AttributeError: 'module' object has no attribute 'Frame'

推荐答案

您在同一目录中有一个本地 wx.py 文件.Python 导入该文件而不是 wx 包.

You have a local wx.py file in the same directory. Python imports that file instead of the wx package.

删除或重命名该文件.

这篇关于wxPython AttributeError:模块没有属性“框架"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆