1 | # Convert all .ui files in all subdirectories of the current script |
---|
2 | import os |
---|
3 | import sys |
---|
4 | |
---|
5 | def pyrrc(in_file, out_file): |
---|
6 | """ Run the pyrcc4 script""" |
---|
7 | execute = 'pyrcc5 %s -o %s' % (in_file, out_file) |
---|
8 | os.system(execute) |
---|
9 | |
---|
10 | def pyuic(in_file, out_file): |
---|
11 | """ Run the pyuic5 script""" |
---|
12 | execute = 'pyuic5 -o %s %s' % (out_file, in_file) |
---|
13 | os.system(execute) |
---|
14 | |
---|
15 | # look for .ui files |
---|
16 | for root, dirs, files in os.walk("."): |
---|
17 | for file in files: |
---|
18 | if file.endswith(".ui"): |
---|
19 | file_in = os.path.join(root, file) |
---|
20 | file_out = os.path.splitext(file_in)[0]+'.py' |
---|
21 | pyuic(file_in, file_out) |
---|
22 | |
---|
23 | # RC file in UI directory |
---|
24 | execute_root = os.path.split(sys.modules[__name__].__file__)[0] |
---|
25 | ui_root = os.path.join(execute_root, 'UI') |
---|
26 | rc_file = 'main_resources.qrc' |
---|
27 | out_file = 'main_resources_rc.py' |
---|
28 | |
---|
29 | pyrrc(os.path.join(ui_root, rc_file), os.path.join(ui_root, out_file)) |
---|
30 | |
---|
31 | # Images |
---|
32 | images_root = os.path.join(execute_root, 'images') |
---|
33 | out_root = os.path.join(execute_root, 'UI') |
---|
34 | rc_file = 'images.qrc' |
---|
35 | out_file = 'images_rc.py' |
---|
36 | pyrrc(os.path.join(images_root, rc_file), os.path.join(out_root, out_file)) |
---|