diff options
author | B Stack <bgstack15@gmail.com> | 2019-06-20 16:21:27 -0400 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2019-06-20 16:21:27 -0400 |
commit | fcd7eadef9545e9f6c6758eb7a1a26deefaa5ede (patch) | |
tree | d34b99fc5e49eb7c36fc615c6461d71b943100c4 | |
parent | WIP: handle failure to load cairo, part 1 (diff) | |
download | logout-manager-fcd7eadef9545e9f6c6758eb7a1a26deefaa5ede.tar.gz logout-manager-fcd7eadef9545e9f6c6758eb7a1a26deefaa5ede.tar.bz2 logout-manager-fcd7eadef9545e9f6c6758eb7a1a26deefaa5ede.zip |
just use an empty icon if not resolvable
-rw-r--r-- | foo | 3 | ||||
-rwxr-xr-x | logout-manager-tcl.py | 8 |
2 files changed, 9 insertions, 2 deletions
@@ -0,0 +1,3 @@ +if LM_USE_SVG == 1, line 256 +also +try: form cairosvg import svg2png diff --git a/logout-manager-tcl.py b/logout-manager-tcl.py index 4d823d5..cc3b2fb 100755 --- a/logout-manager-tcl.py +++ b/logout-manager-tcl.py @@ -39,7 +39,7 @@ import lmlib LM_USE_SVG = 0 try: - from cairosvgf import svg2png + from cairosvg import svg2png LM_USE_SVG = 1 except: print("WARNING: Unable to import cairosvg. No svg images will be displayed.") @@ -274,6 +274,10 @@ def photoimage_from_svg(filename = "",size = "48"): item = svg2png(url=filename, parent_width = size, parent_height = size) return ImageTk.PhotoImage(data=item) +def empty_photoimage(size=24): + photo = Image.new("RGBA",[size,size]) + return ImageTk.PhotoImage(image=photo) + def image_from_svg(filename = "",size = "48"): # open svg if LM_USE_SVG == 1: @@ -311,7 +315,7 @@ def get_scaled_icon(icon_name, size = 24, icon_theme = "default", fallback_icon_ except Exception as f: print("Error with icon file.") print(f) - return None + return empty_photoimage() photo.thumbnail(size=[size, size]) try: photo = ImageTk.PhotoImage(photo) |