Hello everyone,
I am having trouble with a wxpython app. I have some images on the ui and they are hardcoded into the code:
self.bitmap_1 = wx.StaticBitmap(self, -1, wx.Bitmap("images/log2.png", wx.BITMAP_TYPE_ANY))
self.bitmap_2 = wx.StaticBitmap(self, -1, wx.Bitmap("images/logo4.png", wx.BITMAP_TYPE_ANY))
This works great if I run the application from it's own folder. If I make a desktop launcher the images do not show because they are looking for images folder. I can not hardcode my own path /home/me/app-folder/images , because this app will be installed on multiple machines in different home directories. Is there a way to embed the image? or some other way to point to install directory image folder?
Thanks,
Brad
p.s. I am freezing the app before install on other machines.
Hello everyone,
I am having trouble with a wxpython app. I have some images on the ui and they are hardcoded into the code:
self.bitmap_1 = wx.StaticBitmap(self, -1, wx.Bitmap("images/log2.png", wx.BITMAP_TYPE_ANY))
self.bitmap_2 = wx.StaticBitmap(self, -1, wx.Bitmap("images/logo4.png", wx.BITMAP_TYPE_ANY))
This works great if I run the application from it's own folder. If I make a desktop launcher the images do not show because they are looking for images folder. I can not hardcode my own path /home/me/app-folder/images , because this app will be installed on multiple machines in different home directories. Is there a way to embed the image? or some other way to point to install directory image folder?
Thanks,
Brad
p.s. I am freezing the app before install on other machines.
See the img2py tool.
ok I can turn the png into a py file, but I cant find any documentation on howto insert into here:
self.bitmap_1 = wx.StaticBitmap(self, -1, wx.Bitmap("images/log2.png", wx.BITMAP_TYPE_ANY))
self.bitmap_2 = wx.StaticBitmap(self, -1, wx.Bitmap("images/logo4.png", wx.BITMAP_TYPE_ANY))
What syntax is used in wx and Python to embed said file.
Thanks again.
Brad
Hello everyone,
I am having trouble with a wxpython app. I have some images on the ui and they are hardcoded into the code:
self.bitmap_1 = wx.StaticBitmap(self, -1, wx.Bitmap("images/log2.png", wx.BITMAP_TYPE_ANY))
self.bitmap_2 = wx.StaticBitmap(self, -1, wx.Bitmap("images/logo4.png", wx.BITMAP_TYPE_ANY))
This works great if I run the application from it's own folder. If I make a desktop launcher the images do not show because they are looking for images folder. I can not hardcode my own path /home/me/app-folder/images , because this app will be installed on multiple machines in different home directories. Is there a way to embed the image? or some other way to point to install directory image folder?
Thanks,
Brad
p.s. I am freezing the app before install on other machines.
See the img2py tool.
ok I can turn the png into a py file, but I cant find any documentation on howto insert into here:
self.bitmap_1 = wx.StaticBitmap(self, -1, wx.Bitmap("images/log2.png", wx.BITMAP_TYPE_ANY))
self.bitmap_2 = wx.StaticBitmap(self, -1, wx.Bitmap("images/logo4.png", wx.BITMAP_TYPE_ANY))
What syntax is used in wx and Python to embed said file.
What is generated is executable Python code, so you just import the module and call the getBitmap function and use the return value:
Or you can use command line parameters to have it generate a specific function name, like is done for the demo, allowing more than one image per module.
Ok, I converted image.(img2py logo.png logo.py)
Then I import new image(import logo)
Then I changed self.bitmap call: self.bitmap_1 = wx.StaticBitmap(self, -1, logo.getBitmap(), wx.BITMAP_TYPE_ANY)
When I run this, I get errors:
Traceback (most recent call last):
File "quick-connect.py", line 166, in <module>
app = MyApp(0)
File "/usr/lib/python2.5/site-packages/wx-2.6-gtk2-unicode/wx/_core.py", line 7700, in __init__
self._BootstrapApp()
File "/usr/lib/python2.5/site-packages/wx-2.6-gtk2-unicode/wx/_core.py", line 7352, in _BootstrapApp
return _core_.PyApp__BootstrapApp(*args, **kwargs)
File "quick-connect.py", line 158, in OnInit
frame_1 = MyFrame(None, -1, "")
File "quick-connect.py", line 18, in __init__
self.bitmap_1 = wx.StaticBitmap(self, -1, logo.getBitmap(), wx.BITMAP_TYPE_ANY)
File "/usr/lib/python2.5/site-packages/wx-2.6-gtk2-unicode/wx/_controls.py", line 1268, in __init__
newobj = _controls_.new_StaticBitmap(*args, **kwargs)
TypeError: Expected a 2-tuple of integers or a wxPoint object.
What am I doing wrong?
Thanks again for the response,
Brad
Ok, I converted image.(img2py logo.png logo.py)
Then I import new image(import logo)
Then I changed self.bitmap call:
self.bitmap_1 = wx.StaticBitmap(self, -1, logo.getBitmap(), wx.BITMAP_TYPE_ANY)
Ok, I converted image.(img2py logo.png logo.py)
Then I import new image(import logo)
Then I changed self.bitmap call:
self.bitmap_1 = wx.StaticBitmap(self, -1, logo.getBitmap(), wx.BITMAP_TYPE_ANY)
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
Ok, I converted image.(img2py logo.png logo.py)
Then I import new image(import logo)
Then I changed self.bitmap call:
self.bitmap_1 = wx.StaticBitmap(self, -1, logo.getBitmap(), wx.BITMAP_TYPE_ANY)