zoukankan      html  css  js  c++  java
  • Undefined variable from import when using wxPython in pydev

    I just downloaded wxPython, and was running some of the sample programs from here. However, on every line that uses a variable from wx.*, I get a "Undefined variable from import error"

     例如:

    import wx 
    class MyFrame(wx.Frame): 
        """ We simply derive a new class of 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() 
    

      

    解决办法:

    删除pydev,然后重新在Window->Preferences->Pydev->Interpreter-Python进行配置即可。

    PyDev finds the references when you setup the interpreter in

    Window->Preferences->Pydev->Interpreter-Python

    If wxPython was not in your site-packages directory when you first setup the interpreter, then the references to the wx objects and names will not be known to the editor lookup function.  To fix this, remove the interpreter from

    Window->Preferences->Pydev->Interpreter-Python

    and then select new.  Re-add the python installation again and press apply.  At this time, Pydev will import all of the site-package objects again and should populate the lookup dictionary.  You'll want to restart Eclipse for changes to take place.

  • 相关阅读:
    Mina、Netty、Twisted一起学(七):公布/订阅(Publish/Subscribe)
    MySQL高可用之——keepalived+互为主从
    JS之BOM
    Mac下利用(xcode)安装git
    计算矩阵边缘元素之和
    什么是猴子补丁(monkey patch)
    协议支撑
    BZOJ 3727 PA2014 Final Zadanie 树形DP
    Linux cat命令
    iOS8新特性
  • 原文地址:https://www.cnblogs.com/hollyspirit/p/2677882.html
Copyright © 2011-2022 走看看