import gi gi.require_version('Gtk', '4.0') from gi.repository import Gtk import os import src.utils as utils import src.book_files as book_files class BookDelete(Gtk.Window): def __init__(self, parent_window, library, book_id, data, on_parent_confirm): Gtk.Window.__init__(self) self._on_parent_confirm = on_parent_confirm utils.configure_dialog(self, parent_window, data['title'], width=None, height=None) box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=20) self.set_child(box) utils.set_margin(box, 20) picture = Gtk.Picture.new_for_filename(f'{library}/{book_id}/cover.png') picture.set_can_shrink(False) box.append(picture) for path in book_files.get(library, book_id): box.append(utils.label(os.path.basename(path))) confirm_button = Gtk.Button(label='Supprimer') confirm_button.connect('clicked', lambda _: self._on_confirm()) box.append(confirm_button) def _on_confirm(self): self._on_parent_confirm() self.close()