Skip to content

Commit

Permalink
added check for qt message box
Browse files Browse the repository at this point in the history
  • Loading branch information
dvida committed Apr 29, 2021
1 parent 69ed03a commit cf2c9af
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions RMS/Formats/FrameInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,22 @@
from RMS.Formats.FRbin import read as readFR, validFRName
from RMS.Formats.Vid import readFrame as readVidFrame
from RMS.Formats.Vid import VidStruct
from RMS.Routines.CustomPyqtgraphClasses import qmessagebox
from RMS.Routines import Image


# Try importaing a Qt message box if available
try:
from RMS.Routines.CustomPyqtgraphClasses import qmessagebox as messagebox
except:

# Otherwise import a tk message box
# tkinter import that works on both Python 2 and 3
try:
from tkinter import messagebox
except:
import tkMessageBox as messagebox


# Import cython functions
import pyximport
pyximport.install(setup_args={'include_dirs': [np.get_include()]})
Expand Down Expand Up @@ -196,7 +208,7 @@ def __init__(self, dir_path, config, single_ff=False, use_fr_files=False):

# Check that there are any FF files in the folder
if not self.ff_list:
qmessagebox(title='File list warning', message='No FF files in the selected folder!')
messagebox(title='File list warning', message='No FF files in the selected folder!')

sys.exit()

Expand Down Expand Up @@ -670,7 +682,7 @@ def __init__(self, dir_path, config, beginning_time=None, detection=False):
self.beginning_datetime = datetime.datetime.strptime(file_name_noext, "%Y%m%d_%H%M%S.%f")

except:
qmessagebox(title="Input error", \
messagebox(title="Input error", \
message="The time of the beginning cannot be read from the file name! Either change the name of the file to be in the YYYYMMDD_hhmmss format, or specify the beginning time using command line options.")

sys.exit()
Expand Down Expand Up @@ -1239,7 +1251,7 @@ def __init__(self, dir_path, config, beginning_time=None, fps=None, detection=Fa
break

if len(self.img_list) == 0:
qmessagebox(title='Input error',
messagebox(title='Input error',
message="Can't find any images in the given directory! Only PNG, JPG and BMP are supported!")
sys.exit()

Expand Down Expand Up @@ -1340,7 +1352,7 @@ def __init__(self, dir_path, config, beginning_time=None, fps=None, detection=Fa
"%Y%m%d_%H%M%S.%f")

except:
qmessagebox(title='Input error',
messagebox(title='Input error',
message='The time of the beginning cannot be read from the file name! Either change the name of the file to be in the YYYYMMDD_hhmmss format, or specify the beginning time using command line options.')
sys.exit()

Expand Down Expand Up @@ -1862,7 +1874,7 @@ def __init__(self, file_path, config, beginning_time=None, fps=None):
self.beginning_datetime = beginning_datetime

except:
qmessagebox(title='Input error', \
messagebox(title='Input error', \
message="Can't parse given DFN file name!")
sys.exit()

Expand Down Expand Up @@ -2049,7 +2061,7 @@ def detectInputTypeFolder(input_dir, config, beginning_time=None, fps=None, skip


if skip_ff_dir:
qmessagebox(title='FF directory',
messagebox(title='FF directory',
message='ManualReduction only works on individual FF files, and not directories with FF files!')
return None

Expand Down Expand Up @@ -2114,7 +2126,7 @@ def detectInputTypeFile(input_file, config, beginning_time=None, fps=None, detec
img_handle = InputTypeDFN(input_file, config, beginning_time=beginning_time, fps=fps)

else:
qmessagebox(title="Input format error",
messagebox(title="Input format error",
message="Couldn\'t find the file type given")
return None

Expand Down

0 comments on commit cf2c9af

Please sign in to comment.