Skip to content

Commit aaa3884

Browse files
committed
icons for other filetypes. Updated generated images
1 parent a64c1f9 commit aaa3884

File tree

200 files changed

+34
-24
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+34
-24
lines changed

NOTES

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[ ] check if secrets.py is needed and draw it in the header
44

5-
[ ] icon images for non-code files
5+
[x] icon images for non-code files
66

7-
[x] add triangles to generated folders
7+
[x] add triangles to generated folders
8+
9+
[ ] Download the bundle JSON data instead of using pre-fetched one

python_generator/create_requirement_image.py

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,9 @@
1717
HIDDEN_TEXT_COLOR = "#808080"
1818

1919
SHOWN_FILETYPES = ["py", "mpy", "bmp", "pcf", "bdf", "wav", "mp3", "json", "txt"]
20-
"""
21-
libraries_to_render = ['adafruit_bitmap_font',
22-
'adafruit_bus_device',
23-
'adafruit_display_shapes',
24-
'adafruit_display_text',
25-
'adafruit_esp32spi',
26-
'adafruit_hashlib',
27-
'adafruit_imageload',
28-
'adafruit_io',
29-
'adafruit_progressbar',
30-
'adafruit_pyportal',
31-
'adafruit_binascii',
32-
'adafruit_button',
33-
'adafruit_ntp',
34-
'adafruit_requests',
35-
'adafruit_sdcard',
36-
'adafruit_touchscreen',
37-
'neopixel',
38-
'simpleio'
39-
]
40-
"""
20+
21+
22+
4123

4224
f = open("adafruit-circuitpython-bundle-20210423.json", "r")
4325
bundle_data = json.load(f)
@@ -54,6 +36,22 @@
5436
file_empty_icon = Image.open('img/file_empty.png')
5537
file_empty_hidden_icon = Image.open('img/file_empty_hidden.png')
5638

39+
file_image_icon = Image.open('img/file_image.png')
40+
file_music_icon = Image.open('img/file_music.png')
41+
file_font_icon = Image.open('img/file_font.png')
42+
43+
FILE_TYPE_ICON_MAP = {
44+
"py": file_icon,
45+
"mpy": file_icon,
46+
"txt": file_empty_icon,
47+
"bmp": file_image_icon,
48+
"wav": file_music_icon,
49+
"mp3": file_music_icon,
50+
"pcf": file_font_icon,
51+
"bdf": file_font_icon,
52+
"json": file_icon
53+
}
54+
5755

5856
def generate_requirement_image(learn_guide_project):
5957
def make_line(requirement_name, position=(0, 0), icon=None, hidden=False, triangle_icon=None):
@@ -126,7 +124,15 @@ def make_header(position, learn_guide_project):
126124

127125

128126
for i, file in enumerate(project_files_to_draw):
129-
make_line(file, (position[0] + INDENT_SIZE, position[1] + (LINE_SPACING * (6 + i ))))
127+
cur_file_extension = file.split(".")[-1]
128+
print("checking {}".format(cur_file_extension))
129+
130+
if cur_file_extension in FILE_TYPE_ICON_MAP:
131+
print("found icon for {}".format(cur_file_extension))
132+
cur_file_icon = FILE_TYPE_ICON_MAP[cur_file_extension]
133+
else:
134+
cur_file_icon = file_empty_icon
135+
make_line(file, (position[0] + INDENT_SIZE, position[1] + (LINE_SPACING * (6 + i ))), icon=cur_file_icon)
130136
rows_added += 1
131137

132138
for i, file in enumerate(project_folders_to_draw):
24 Bytes
-16 Bytes
-3 Bytes
-7 Bytes
171 Bytes
-16 Bytes
2.39 KB
-13 Bytes

0 commit comments

Comments
 (0)