Skip to content

Commit 7df096d

Browse files
committed
add icon on thumbnails
1 parent c21e9b6 commit 7df096d

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

file.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ def display_files(self):
103103
else:
104104
parent = self.tree.insert(parent, "end", text=subfolder, open=True)
105105
for file_name in file_list:
106-
thumbnail = self.load_thumbnail(file_name)
106+
parent_folder_path = os.path.join(self.sdk.parent_folder, folder) # Define parentFolder
107+
thumbnail = self.load_thumbnail(file_name, parent_folder_path)
107108
if thumbnail:
108109
self.tree.insert(parent, "end", text=file_name, image=thumbnail, tags=(folder,))
109110
else:
@@ -160,7 +161,7 @@ def clear_selections(self):
160161
for item in self.tree.selection():
161162
self.tree.selection_remove(item)
162163

163-
def load_thumbnail(self, file_path):
164+
def load_thumbnail(self, file_path, parent=""):
164165
"""
165166
Load the appropriate thumbnail for a given file path.
166167
@@ -189,19 +190,23 @@ def load_thumbnail(self, file_path):
189190
".cfg": "txt.png",
190191
".sln": "Visual_Studio.png",
191192
".vpk": "fileexplorer.png",
192-
#".wav": "audio.png",
193-
#".mp3": "audio.png",
194-
#".bik": "video.png",
195-
".bat": "terminal.png",
193+
".wav": "audio.png",
194+
".mp3": "audio.png",
195+
".bik": "video.png",
196+
".bat": "terminal.png"
196197
}
197198

198199
#ext = os.path.splitext(file_path)[1]
199200
file_name, file_extension = os.path.splitext(file_path)
200201

201-
if file_extension in file_icons and file_icons[file_extension]:
202-
image = Image.open(os.path.join(base_path, "icons", file_icons[file_extension]))
202+
if file_extension in file_icons:
203+
if file_icons[file_extension]:
204+
image = Image.open(os.path.join(base_path, "icons", file_icons[file_extension]))
205+
else:
206+
image = Image.open(parent + "/" + file_path)
203207
elif os.path.isdir(file_path):
204208
image = Image.open(os.path.join(base_path, "icons", "fileexplorer.png"))
209+
205210

206211
if image:
207212
image.thumbnail((16, 16))

fileListApp.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ def load_thumbnail(self, file_path):
136136
".smd": "txt.png",
137137
".cfg": "txt.png",
138138
".sln": "Visual_Studio.png",
139-
".bat": "terminal.png"
139+
".bat": "terminal.png",
140+
".wav": "audio.png",
141+
".mp3": "audio.png",
142+
".bik": "video.png"
140143
}
141144

142145
ext = os.path.splitext(file_path)[1]

icons/audio.png

1.54 KB
Loading

icons/video.png

12.8 KB
Loading

0 commit comments

Comments
 (0)