mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
Load icons from either images/misc or images/icons
This commit is contained in:
parent
f5b1cf0eea
commit
e5e60d3232
2 changed files with 16 additions and 4 deletions
|
@ -168,9 +168,20 @@ class DataLoader:
|
||||||
return self.findFile(filename, subdirs)
|
return self.findFile(filename, subdirs)
|
||||||
|
|
||||||
def findAllIconSizes(self, filename='pysol.png'):
|
def findAllIconSizes(self, filename='pysol.png'):
|
||||||
|
try:
|
||||||
icondir = self.findDir(os.path.join('images', 'icons'))
|
icondir = self.findDir(os.path.join('images', 'icons'))
|
||||||
icons = [os.path.join(icondir, subdir, filename) for subdir in
|
icons = [os.path.join(icondir, subdir, filename) for subdir in
|
||||||
os.listdir(icondir)]
|
os.listdir(icondir)]
|
||||||
|
except OSError:
|
||||||
|
try:
|
||||||
|
# pysol06.png is known to have transparent borders around it
|
||||||
|
# which is unsuitable for a window icon
|
||||||
|
icon_blacklist = ('pysol06.png',)
|
||||||
|
miscdir = self.findDir(os.path.join('images', 'misc'))
|
||||||
|
icons = [os.path.join(miscdir, f) for f in os.listdir(miscdir)
|
||||||
|
if f not in icon_blacklist]
|
||||||
|
except OSError:
|
||||||
|
icons = []
|
||||||
return filter(os.path.isfile, icons)
|
return filter(os.path.isfile, icons)
|
||||||
|
|
||||||
def findDir(self, filename, subdirs=None):
|
def findDir(self, filename, subdirs=None):
|
||||||
|
|
|
@ -93,6 +93,7 @@ def base_init_root_window(root, app):
|
||||||
|
|
||||||
if TOOLKIT == 'tk':
|
if TOOLKIT == 'tk':
|
||||||
icons = [loadImage(img) for img in app.dataloader.findAllIconSizes()]
|
icons = [loadImage(img) for img in app.dataloader.findAllIconSizes()]
|
||||||
|
if icons:
|
||||||
root.wm_iconphoto(True, *icons)
|
root.wm_iconphoto(True, *icons)
|
||||||
|
|
||||||
# set minsize
|
# set minsize
|
||||||
|
|
Loading…
Add table
Reference in a new issue