#!/usr/bin/env python3
from os import scandir
from os.path import splitext
+from exiftool import ExifToolHelper # type: ignore
import gi
gi.require_version('Gtk', '4.0')
# pylint: disable=wrong-import-position
btn.connect('clicked', self.newest)
box_buttons.append(btn)
- self.label_nothing = Gtk.Label(label='nothing to show')
+ self.metadata = Gtk.Label()
+ self.label_nothing_to_show = Gtk.Label(label='nothing to show')
self.box_outer = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.box_outer.append(box_buttons)
- self.box_outer.append(self.label_nothing)
+ self.box_outer.append(self.metadata)
+ self.box_outer.append(self.label_nothing_to_show)
self.props.child = self.box_outer
self.entries = []
- self.current_index = -1
+ self.current_index = -1
self.newest(None)
def _reload(self, set_max = False):
- self.entries = [e for e in scandir('./empty')
+ self.entries = [e for e in scandir('.')
if e.is_file()
and splitext(e)[1] in {'.png', '.jpg', '.jpeg'}]
self.entries.sort(key=lambda e: e.stat().st_mtime)
self.current_index = len(self.entries) - 1
self.box_outer.remove(self.box_outer.get_last_child())
if self.current_index >= 0:
- pic = Gtk.Picture.new_for_filename(self.entries[self.current_index].path)
+ path = self.entries[self.current_index].path
+ metadata = 'no SD comment'
+ with ExifToolHelper() as et:
+ for d in et.get_tags([path], ['Comment']):
+ for k, v in d.items():
+ if k.endswith('Comment'):
+ metadata = v
+ self.metadata.props.label = f'{path}: {metadata}'
+ pic = Gtk.Picture.new_for_filename(path)
self.box_outer.append(pic)
else:
- self.box_outer.append(self.label_nothing)
+ self.metadata.props.label = None
+ self.box_outer.append(self.label_nothing_to_show)
def oldest(self, _widget):
self.current_index = 0