File: EmbedRAWIcons.py

package info (click to toggle)
bioxtasraw 2.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 275,072 kB
  • sloc: python: 74,496; makefile: 29; sh: 21
file content (71 lines) | stat: -rw-r--r-- 2,271 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""
Created on January 14, 2015

@author: Jesse B. Hopkins


The purpose of this module is to create a file which contains wxpython embedded images
all of the files in a directory. The purpose is to make code packaging easier, by removing
the need to package extra resource files. Everything will instead be in a python file.

#******************************************************************************
# This file is part of RAW.
#
#    RAW is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    RAW is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with RAW.  If not, see <http://www.gnu.org/licenses/>.
#
#******************************************************************************

"""

import os
import glob
import sys
from wx.tools.img2py import img2py
import time

RAWWorkDir = sys.path[0]

RAWResourceDir = RAWWorkDir + '/resources/'

png_list = glob.glob(RAWResourceDir+'*.png')
ico_list = glob.glob(RAWResourceDir+'*.ico')
gif_list = glob.glob(RAWResourceDir+'*.gif')

image_list = png_list + ico_list + gif_list

img_code = ''

for i in range(len(image_list)):
    image = image_list[i]

    if image.split('.')[-1] == '.ico':
        img2py(image,RAWWorkDir+'/temp.py', icon=True)
    else:
        img2py(image,RAWWorkDir+'/temp.py')

    f = open(RAWWorkDir+'/temp.py','r')
    code = f.readlines()
    f.close()
    for line in code:
        img_code = img_code + line


os.remove(RAWWorkDir+'/temp.py')

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"

f = open('RAWIcons.py','w')
f.write(file_header)
f.write(img_code)
f.close()