views:

63

answers:

2

I tried the following example code from the tutorial that came along "wxPython2.8 Docs and Demos" package.

import wx

from frame import Frame

class App(wx.App):
    """Application class."""

    def OnInit(self):
        self.frame = Frame()
        self.frame.Show()
        self.SetTopWindow(self.frame)
        return True

def main():
    app = App()
    app.MainLoop()

if __name__ == '__main__':
    main()

but its giving me the following error

Traceback (most recent call last):
  File "C:/Documents and Settings/umair.ahmed/Desktop/wxpy.py", line 3, in <module>
    from frame import Frame
ImportError: No module named frame

kindly help i am just a newbie with python

+1  A: 

I think you should skip the "from frame import Frame" and change:

self.frame = Frame()

to:

self.frame = wx.Frame()
Ned Batchelder
Thanx. But i needed to change self.frame = Frame() to self.frame = wx.Frame(None)
Umair Ahmed
+1  A: 

Yeah, it's an ancient doc bug, see for example this 5-years-old post:-(. Fix:

  • delete the line that says from frame import Frame
  • change the line that says self.frame = Frame() to say instead self.frame = wx.Frame()
Alex Martelli