add pdf viewer to gui tools #119

Merged
holler merged 2 commits from holler-docs into main 2026-01-06 12:53:50 +01:00
2 changed files with 25 additions and 2 deletions

View File

@@ -20,6 +20,7 @@ class flomniGuiTools:
def __init__(self):
self.text_box = None
self.progressbar = None
self.pdf_viewer = None
def set_client(self, client):
self.client = client
@@ -97,6 +98,7 @@ class flomniGuiTools:
self.gui.flomni.delete_all()
self.progressbar = None
self.text_box = None
self.pdf_viewer = None
def flomnigui_idle(self):
self.flomnigui_show_gui()
@@ -114,6 +116,27 @@ class flomniGuiTools:
)
idle_text_box.set_html_text(text)
def flomnigui_docs(self):
import csaxs_bec
from pathlib import Path
# Ensure this is a Path object, not a string
csaxs_bec_basepath = Path(csaxs_bec.__file__)
pdf_file = "FZP_flomni_with_CS.pdf"
# Build the absolute path correctly
pdf_file = (
csaxs_bec_basepath.parent / 'bec_ipython_client' / 'plugins' / 'flomni' / 'docs' / pdf_file
).resolve()
if self.pdf_viewer is None:
self.flomnigui_show_gui()
self.flomnigui_remove_all_docks()
self.pdf_viewer = self.gui.flomni.new(widget="PdfViewerWidget")
self.pdf_viewer.PdfViewerWidget.load_pdf(str(pdf_file))
def _flomnicam_check_device_exists(self, device):
try:
device
@@ -156,8 +179,8 @@ class flomniGuiTools:
)
self.progressbar.set_value([progress, subtomo_progress, 0])
if self.text_box is not None:
text = f"Progress report:\n Tomo type: ....................... {self.progress['tomo_type']}\n Projection: ...................... {self.progress['projection']:.0f}\n Total projections expected ....... {self.progress['total_projections']}\n Angle: ........................... {self.progress['angle']}\n Current subtomo: ................. {self.progress['subtomo']}\n Current projection within subtomo: {self.progress['subtomo_projection']}\n Total projections per subtomo: ... {self.progress['subtomo_total_projections']}"
self.text_box.set_plain_text(text)
text = f"Progress report:\n Tomo type: ....................... {self.progress['tomo_type']}\n Projection: ...................... {self.progress['projection']:.0f}\n Total projections expected ....... {self.progress['total_projections']}\n Angle: ........................... {self.progress['angle']}\n Current subtomo: ................. {self.progress['subtomo']}\n Current projection within subtomo: {self.progress['subtomo_projection']}\n Total projections per subtomo: ... {self.progress['subtomo_total_projections']}"
self.text_box.set_plain_text(text)
if __name__ == "__main__":