From cd2138c0f86f7ca652f897f7c5838509f5fe959f Mon Sep 17 00:00:00 2001 From: villekf Date: Thu, 18 Jul 2024 11:03:10 +0300 Subject: [PATCH] Fix for case when no ROOT files are found --- source/Python/omegatomo/io/loadData.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/Python/omegatomo/io/loadData.py b/source/Python/omegatomo/io/loadData.py index 019efbd..98f9804 100644 --- a/source/Python/omegatomo/io/loadData.py +++ b/source/Python/omegatomo/io/loadData.py @@ -136,6 +136,17 @@ def loadROOT(options, store_coordinates = False): else: files = glob.glob(os.path.join(options.fpath, '*.root')) nFiles = len(files) + if nFiles == 0: + print('No files found! Please select a ROOT file') + import tkinter as tk + from tkinter.filedialog import askopenfilename + root = tk.Tk() + root.withdraw() + filename = askopenfilename(title='Select first ROOT file',filetypes=([('ROOT Files','*.root')])) + if not filename: + raise ValueError('No file was selected') + files = glob.glob(os.path.join(os.path.split(filename)[0], '*.root')) + nFiles = len(files)