aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlogout-manager-tcl.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/logout-manager-tcl.py b/logout-manager-tcl.py
index 9d8f999..c8ba228 100755
--- a/logout-manager-tcl.py
+++ b/logout-manager-tcl.py
@@ -246,7 +246,7 @@ def get_filename_of_icon(name, theme = "hicolor", size = 48, category = "actions
# first, find all files underneath /usr/share/icons/$THEME/$SIZE
print("Finding filename of icon, theme=",theme,"category=",category,"name=",name)
- # FUTUREIMPROVEMENT: this glob affects if scalable/ dir is included. When support for svg is added (which is beyond PIL), need to add a conditional and use a second glob if USE_SVG=1.
+ # IMPROVEHERE: this glob affects if scalable/ dir is included. When support for svg is added (which is beyond PIL), need to add a conditional and use a second glob if USE_SVG=1.
# to exclude the scalable/ contents, replace dir 5 asterisk with [0-9]*
results = []
# COMMENTED to test with the svg. results = glob.glob("/usr/share/icons/"+theme+"/*/"+category+"/"+name+".{png,PNG}")
@@ -269,8 +269,9 @@ def photoimage_from_svg(filename = "",size = "48"):
def image_from_svg(filename = "",size = "48"):
# open svg
- item = cairosvg.svg2png(url=filename,parent_width = size,parent_height = size)
- return ImageTk.PhotoImage(data=item)
+ cairosvg.svg2png(url=filename,write_to="/tmp/file3.png",parent_width = size,parent_height = size)
+ photo = Image.open("/tmp/file3.png")
+ return photo
def get_scaled_icon(icon_name, size = 24, icon_theme = "default", fallback_icon_name = ""):
iconfilename = None
@@ -294,17 +295,17 @@ def get_scaled_icon(icon_name, size = 24, icon_theme = "default", fallback_icon_
# try an svg
if re.compile(".*\.svg").match(iconfilename):
print("Trying svg...")
- photo = photoimage_from_svg(filename=iconfilename, size=size)
+ photo = image_from_svg(filename=iconfilename, size=size)
else:
photo = Image.open(iconfilename)
- photo.thumbnail(size=[size, size])
- try:
- photo = ImageTk.PhotoImage(photo)
- except Exception as e:
- print("Error was ",e)
except:
print("Error with icon file.")
return None
+ photo.thumbnail(size=[size, size])
+ try:
+ photo = ImageTk.PhotoImage(photo)
+ except Exception as e:
+ print("Error was ",e)
# If I ever add HiDPI support, multiple size here by the factor. So, size * 1.25
return photo
bgstack15