| 1 |
""" |
| 2 |
Created on January 14, 2015 |
| 3 |
|
| 4 |
@author: Jesse B. Hopkins |
| 5 |
|
| 6 |
|
| 7 |
The purpose of this module is to create a file which contains wxpython embedded images |
| 8 |
all of the files in a directory. The purpose is to make code packaging easier, by removing |
| 9 |
the need to package extra resource files. Everything will instead be in a python file. |
| 10 |
|
| 11 |
#****************************************************************************** |
| 12 |
# This file is part of RAW. |
| 13 |
# |
| 14 |
# RAW is free software: you can redistribute it and/or modify |
| 15 |
# it under the terms of the GNU General Public License as published by |
| 16 |
# the Free Software Foundation, either version 3 of the License, or |
| 17 |
# (at your option) any later version. |
| 18 |
# |
| 19 |
# RAW is distributed in the hope that it will be useful, |
| 20 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
# GNU General Public License for more details. |
| 23 |
# |
| 24 |
# You should have received a copy of the GNU General Public License |
| 25 |
# along with RAW. If not, see <http://www.gnu.org/licenses/>. |
| 26 |
# |
| 27 |
#****************************************************************************** |
| 28 |
|
| 29 |
""" |
| 30 |
|
| 31 |
import os |
| 32 |
import glob |
| 33 |
import sys |
| 34 |
from wx.tools.img2py import img2py |
| 35 |
import time |
| 36 |
|
| 37 |
RAWWorkDir = sys.path[0] |
| 38 |
|
| 39 |
RAWResourceDir = RAWWorkDir + '/resources/' |
| 40 |
|
| 41 |
png_list = glob.glob(RAWResourceDir+'*.png') |
| 42 |
ico_list = glob.glob(RAWResourceDir+'*.ico') |
| 43 |
gif_list = glob.glob(RAWResourceDir+'*.gif') |
| 44 |
|
| 45 |
image_list = png_list + ico_list + gif_list |
| 46 |
|
| 47 |
img_code = '' |
| 48 |
|
| 49 |
for i in range(len(image_list)): |
| 50 |
image = image_list[i] |
| 51 |
|
| 52 |
if image.split('.')[-1] == '.ico': |
| 53 |
img2py(image,RAWWorkDir+'/temp.py', icon=True) |
| 54 |
else: |
| 55 |
img2py(image,RAWWorkDir+'/temp.py') |
| 56 |
|
| 57 |
f = open(RAWWorkDir+'/temp.py','r') |
| 58 |
code = f.readlines() |
| 59 |
f.close() |
| 60 |
for line in code: |
| 61 |
img_code = img_code + line |
| 62 |
|
| 63 |
|
| 64 |
os.remove(RAWWorkDir+'/temp.py') |
| 65 |
|
| 66 |
file_header = "'''Created on " + time.ctime() + "\n\n@author: Jesse B. Hopkins\n\nThis module contains embedded image data for all of the image\nfiles in the resources directory. It was generated using the\nwx.tools.img2py.img2py function, and automated with the\nEmbeddedRAWIcons.py file.\n\n'''\n\n" |
| 67 |
|
| 68 |
f = open('RAWIcons.py','w') |
| 69 |
f.write(file_header) |
| 70 |
f.write(img_code) |
| 71 |
f.close() |