Search code examples
pythonwxpythonwxwidgets

Why wxPython applications are slow to start?


Is there anyway to speedup start-up for wxPython? It takes usually around 5 seconds for the application to start on my Ubuntu machine, even when I write the most simple ones!

import wx

class MyApp(wx.App):
        def OnInit(self):
                frame = wx.Frame(None, id = wx.ID_ANY, title = u"Duplicate Detector", pos = wx.DefaultPosition, size = wx.Size( 800,600 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
                frame.Show(True)
                return True

if __name__ == "__main__":
    app = MyApp(redirect=False)
    app.MainLoop()

The tiny bit of code above, takes some times to load.


Solution

  • wxPython is a big package, and takes a non-trivial amount of time to load. Other toolkits may take less time, but the effort to port an app may not be worth it.

    $ time python -c 'import wx'
    
    real    0m1.646s
    user    0m0.306s
    sys     0m0.079s