Skip to content
Snippets Groups Projects
Commit 09cfb0b7 authored by Unknown's avatar Unknown
Browse files

New uigetfile

This version trys to import PyQt5 within the function.  It catches ImportErrors and should allow for pycroscopy to be imported even if PyQt5 is not found.
parent 10983611
No related branches found
No related tags found
1 merge request!97Cades dev
......@@ -9,12 +9,47 @@ from __future__ import division, print_function, absolute_import, unicode_litera
from multiprocessing import cpu_count
from time import strftime
from psutil import virtual_memory as vm
from warnings import warn
import h5py
import numpy as np
__all__ = ['getAvailableMem', 'getTimeStamp', 'transformToTargetType', 'transformToReal',
'complex_to_float', 'compound_to_scalar', 'realToComplex', 'realToCompound', 'check_dtype',
'recommendCores']
'recommendCores', 'uiGetFile']
def uiGetFile(filter='H5 file (*.h5)', caption='Select File'):
"""
Presents a File dialog used for selecting the .mat file
and returns the absolute filepath of the selecte file\n
Parameters
----------
extension : String or list of strings
file extensions to look for
caption : (Optional) String
Title for the file browser window
Returns
-------
file_path : String
Absolute path of the chosen file
"""
try:
from PyQt5 import QtWidgets
except ImportError:
warn('The required package PyQt5 could not be imported.\n',
'Exiting uigetfile. The user should specify the file path manually.')
return None
except:
raise
app = QtWidgets.QApplication([])
path = QtWidgets.QFileDialog.getOpenFileName(caption=caption, filter=filter)[0]
app.exit()
del app
return str(path)
def getTimeStamp():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment