From ea5c5afa5e2170bdd688a153692ae5f8f27565b1 Mon Sep 17 00:00:00 2001 From: alfrix Date: Wed, 17 Aug 2022 14:36:25 -0300 Subject: [PATCH] gtk: do not try to ellipsize if the label is None --- ks_includes/KlippyGtk.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/ks_includes/KlippyGtk.py b/ks_includes/KlippyGtk.py index b8a92a2e..19a7044c 100644 --- a/ks_includes/KlippyGtk.py +++ b/ks_includes/KlippyGtk.py @@ -173,16 +173,17 @@ class KlippyGtk: b.set_image_position(position) b.set_always_show_image(True) - try: - # Get the label object - child = b.get_children()[0].get_children()[0].get_children()[1] - child.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR) - child.set_line_wrap(True) - child.set_ellipsize(True) - child.set_ellipsize(Pango.EllipsizeMode.END) - child.set_lines(lines) - except Exception as e: - logging.debug(f"Unable to wrap and ellipsize label: {e}") + if label is not None: + try: + # Get the label object + child = b.get_children()[0].get_children()[0].get_children()[1] + child.set_line_wrap_mode(Pango.WrapMode.WORD_CHAR) + child.set_line_wrap(True) + child.set_ellipsize(True) + child.set_ellipsize(Pango.EllipsizeMode.END) + child.set_lines(lines) + except Exception as e: + logging.debug(f"Unable to wrap and ellipsize label: {image_name} {label} {e}") if style is not None: b.get_style_context().add_class(style)