From fcd7eadef9545e9f6c6758eb7a1a26deefaa5ede Mon Sep 17 00:00:00 2001 From: B Stack Date: Thu, 20 Jun 2019 16:21:27 -0400 Subject: just use an empty icon if not resolvable --- foo | 3 +++ logout-manager-tcl.py | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 foo diff --git a/foo b/foo new file mode 100644 index 0000000..920b34d --- /dev/null +++ b/foo @@ -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) -- cgit