For future reference: Pass redirect=False to your wx.App initializer,
and run your code from a console. You will see tracebacks printed on
the console, instead of being redirected to a logging window. For
errors that occur during application startup, this is very much to be
preferred.
···
On 7/11/07, Kevin Walzer <kw@codebykevin.com> wrote:
Kevin Walzer wrote:
> The following script crashes when I try to run it, or more specifically,
> it flashes a window and exits immediately. The problem seems to be in
> the self.makeImages() function, because calling that function, it loads
> and runs fine.
>
> I can't quite figure out what's going on. The main window appears to
> print out a traceback, but exits before I can read it. It doesn't print
> out the traceback in my console.
>
> What I'm trying to do with the makeImages() function is to load all the
> images my application will use as toolbar images, listbox icons, etc.,
> into memory.
>
> To test, just create a directory called "images" in the script's working
> directory, then put a png file in the "images" directory, and name the
> file appropriately (or change the name of the png in the script).
>
> I'm using wxPython 2.8.4, Python 2.5.1, on OS X 10.4.10.
>
> Any help is appreciated.
>
> ----
> import wx
> import os
>
> class simpleapp_wx(wx.Frame):
> def __init__(self,parent,id,title):
> wx.Frame.__init__(self,parent,id,title)
> self.parent = parent
> self.initialize()
> self.makeImages()
>
> def initialize(self):
> sizer = wx.GridBagSizer()
>
> self.entry = wx.TextCtrl(self,-1,value=u"Enter text here.")
> sizer.Add(self.entry,(0,0),(1,1),wx.EXPAND)
>
> self.SetSizerAndFit(sizer)
> self.Show(True)
>
> def makeImages(self):
>
> self.imagedir = (os.getcwd() + '/images/')
> self.triangledown=wx.Bitmap((self.imagdir + 'triangledown.png'),
> wx.BITMAP_TYPE_PNG)
>
> if __name__ == "__main__":
> app = wx.App()
> frame = simpleapp_wx(None,-1,'my application')
> app.MainLoop()
>
D'oh. Changing 'self.imagedir' to 'imagedir' solved the problem...