Hey guys trying to compile code, and heres the error I receive. im fairly new to python programming so any help would be appreciated. thanks in advance.
ms7538@ms:~/Desktop$ ./test.py
Traceback (most recent call last):
File "./test.py", line 10, in <module>
class Panel1(wx.Panel):
File "./test.py", line 22, in Panel1
bmp = wx.BitmapFromImage( wx.ImageFromStream( stream ))
File "/usr/lib/python2.5/site-packages/wx-2.6-gtk2-unicode/wx/_gdi.py", line 749, in BitmapFromImage
val = _gdi_.new_BitmapFromImage(*args, **kwargs)
wx._core.PyNoAppError: The wx.App object must be created first!

Recommended Answers

All 2 Replies

When you use wxPython, as with Tkinter, the application has to be initialized first in order to set all kinds of screen parameters.

So the code you are trying to compile is only partially there. Did you write it yourself, or is it someone else's?

You should start your wxPython program with something like that:

app = wx.App(0)
MyFrame(None, -1, 'frame title')
app.MainLoop()

or that:

class MyApp(wx.App):
    def OnInit(self):
        frame = MyFrame(None, -1, 'frame title')
        frame.Show(True)
        self.SetTopWindow(frame)
        return True

app = MyApp(0)
app.MainLoop()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.