aboutsummaryrefslogtreecommitdiff
path: root/logout-manager-tcl.py
diff options
context:
space:
mode:
Diffstat (limited to 'logout-manager-tcl.py')
-rwxr-xr-xlogout-manager-tcl.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/logout-manager-tcl.py b/logout-manager-tcl.py
index cfeb851..0a0a1f7 100755
--- a/logout-manager-tcl.py
+++ b/logout-manager-tcl.py
@@ -29,11 +29,8 @@
# tkinter: python36-tkinter | python3-tk
# PIL: python36-pillow-tk | python3-pil.imagetk
# cairo: python36-cairo | python3-cairo
-# Rsvg: python36-gobject | python3-gobject
+# Rsvg: python36-gobject | gir1.2-rsvg-3.0
-from gi import require_version
-require_version('Rsvg', '2.0')
-from gi.repository import Rsvg
import os, sys, configparser, glob, re, cairo
import tkinter as tk
import tkinter.ttk as ttk
@@ -42,6 +39,11 @@ from pathlib import Path
from PIL import Image, ImageTk
sys.path.append("/home/bgirton/dev/logout-manager")
import lmlib
+WITH_SVG=True
+if not WITH_SVG is None and WITH_SVG:
+ from gi import require_version
+ require_version('Rsvg', '2.0')
+ from gi.repository import Rsvg as rsvg
#if TkVersion < 8.6:
# USE_PRIVATE_TCL_IMAGES = 1
# print("Loading private PIL translation layter")
@@ -86,7 +88,7 @@ def convert(bgra_buffer, width, height):
def photoimage_from_svg(file_path_name):
'''Return a Tkinter.PhotoImage with the content set to the rendered SVG.'''
- svg = rsvg.Handle(file=file_path_name)
+ svg = rsvg.Handle(file_path_name)
width, height = svg.get_dimension_data()[:2]
surface = cairo.ImageSurface(cairo.FORMAT_RGB24, int(width), int(height))
context = cairo.Context(surface)
@@ -349,8 +351,10 @@ def get_scaled_icon(icon_name, size = 24, icon_theme = "default", fallback_icon_
photo = photoimage_from_svg(iconfilename)
else:
photo = Image.open(iconfilename)
- except:
- print("Error with icon file.")
+ except Exception as e:
+ print("Error with icon file:",e)
+ if "gobject" in str(e):
+ raise
return None
# If I ever add HiDPI stuff, multiple size here by the factor. So, size * 1.25
photo.thumbnail(size=[size, size])
bgstack15