Hello everyone,
I am trying to build a .exe app using pyinstaller to make it standalone.
I have an issue with the background image, I am using wxPython for the gui.
My background image file is not in the .exe, it has to be in the folder where my .exe is else my program is not working.
Every other dll, icon file, whatever else my program needs is in the standalone .exe.
If anyone would know how to integrate my image file to make sure this is a standalone .exe this would be perfect.
The important part of my code for this is the following:
class MainPanel(wx.Panel):
""""""
def OnClose(self, e):
parse.parsing()
def __init__(self, parent):
"""Constructor"""
wx.Panel.__init__(self, parent=parent)
#self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
self.frame = parent
sizer = wx.BoxSizer(wx.VERTICAL)
hSizer = wx.BoxSizer(wx.HORIZONTAL)
cbtn = wx.Button(self, label='Configure', pos=(196, 144))
cbtn.Bind(wx.EVT_BUTTON, self.OnClose)
self.SetSizer(hSizer)
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
def OnEraseBackground(self, evt):
"""
Background image
"""
# yanked from ColourDB.py
dc = evt.GetDC()
if not dc:
dc = wx.ClientDC(self)
rect = self.GetUpdateRegion().GetBox()
dc.SetClippingRect(rect)
dc.Clear()
bmp = wx.Bitmap("pf_bg.png")
dc.DrawBitmap(bmp, 0, 0)
For information when compiling with pyinstaller I use the following:
python pyinstaller.py --version-file=version.txt -F --noconsole --icon=ic.ico -n blabla gui.py
When I try to open my .exe without my image file in the folder I have the error in the attached file.
I am not sure if I have to fix something with wx or pyinstaller.
Everything is compile on win7(64) with python 2.6.6
Thanks,
Antoine