# Python imports # Lib imports import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk # Application imports class PathLabel(Gtk.Label): def __init__(self): super(PathLabel, self).__init__() self._setup_styling() self._setup_signals() self._subscribe_to_events() self._load_widgets() self.show_all() def _setup_styling(self): self.set_line_wrap(False) self.set_ellipsize(1) # NONE = 0¶, START = 1¶, MIDDLE = 2¶, END = 3¶ def _setup_signals(self): self.set_margin_left(25) self.set_margin_right(25) self.set_margin_top(5) self.set_margin_bottom(10) def _subscribe_to_events(self): event_system.subscribe("update_path_label", self.update_path_label) def _load_widgets(self): ... def update_path_label(self, path = None): if not path: return self.set_label(path) self.set_tooltip_text(path)