diff --git a/conda/environment.yml b/conda/environment.yml index f9d6166..b79e311 100644 --- a/conda/environment.yml +++ b/conda/environment.yml @@ -11,5 +11,4 @@ dependencies: - matplotlib - pandas - numpy - - pyqt5-sip - pyproj \ No newline at end of file diff --git a/conda/meta.yaml b/conda/meta.yaml index c83e175..8ad2036 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -23,7 +23,6 @@ requirements: - matplotlib - pandas - numpy - - PyQt5 - pyproj about: diff --git a/pyproject.toml b/pyproject.toml index 54b8fa8..f44758c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ version="0.1.42" description = "A package for processing and analyzing HVSR (Horizontal to Vertical Spectral Ratio) data" keywords = ["HVSR", "seismic", "horizontal to vertical spectral ratio", "obspy", 'geology', 'geophysics', 'geotechnical'] requires-python = ">=3.9" -dependencies = ["obspy", "scipy", "matplotlib", "pandas", "numpy", "PyQt5", "pyproj"] +dependencies = ["obspy", "scipy", "matplotlib", "pandas", "numpy", "pyproj"] classifiers = [ "Programming Language :: Python :: 3", "Intended Audience :: Science/Research", diff --git a/sprit/__init__.py b/sprit/__init__.py index 09e661b..8ba1844 100644 --- a/sprit/__init__.py +++ b/sprit/__init__.py @@ -27,6 +27,7 @@ ) from sprit.sprit_utils import( + check_gui_requirements, checkifpath, check_mark, check_tsteps, @@ -67,6 +68,7 @@ 'HVSRData', 'HVSRBatch', 'sprit_utils', + 'check_gui_requirements', 'checkifpath', 'check_mark', 'check_tsteps', diff --git a/sprit/sprit_gui.py b/sprit/sprit_gui.py index 064ec11..794a176 100644 --- a/sprit/sprit_gui.py +++ b/sprit/sprit_gui.py @@ -1,6 +1,5 @@ """This script contains all the functions, classes, etc. to create a tkinter app for graphical user interface. """ - import datetime import functools import linecache @@ -3038,19 +3037,24 @@ def on_closing(): exit() if __name__ == "__main__": - root = tk.Tk() - try: + can_gui = sprit_utils.check_gui_requirements() + print(can_gui) + if can_gui: + root = tk.Tk() try: - icon_path =pathlib.Path(pkg_resources.resource_filename(__name__, 'resources/icon/sprit_icon_alpha.ico')) - root.iconbitmap(icon_path) - except: - icon_path = pathlib.Path(pkg_resources.resource_filename(__name__, 'resources/icon/sprit_icon.png')) - root.iconphoto(False, tk.PhotoImage(file=icon_path.as_posix())) - except Exception as e: - print("ICON NOT LOADED, still opening GUI") - - root.resizable(True, True) - spritApp =SPRIT_App(root) - - root.protocol("WM_DELETE_WINDOW", on_closing) - root.mainloop() + try: + icon_path =pathlib.Path(pkg_resources.resource_filename(__name__, 'resources/icon/sprit_icon_alpha.ico')) + root.iconbitmap(icon_path) + except: + icon_path = pathlib.Path(pkg_resources.resource_filename(__name__, 'resources/icon/sprit_icon.png')) + root.iconphoto(False, tk.PhotoImage(file=icon_path.as_posix())) + except Exception as e: + print("ICON NOT LOADED, still opening GUI") + + root.resizable(True, True) + spritApp =SPRIT_App(root) + + root.protocol("WM_DELETE_WINDOW", on_closing) + root.mainloop() + else: + print("GUI cannot be created") diff --git a/sprit/sprit_utils.py b/sprit/sprit_utils.py index 5f66154..415a897 100644 --- a/sprit/sprit_utils.py +++ b/sprit/sprit_utils.py @@ -2,6 +2,7 @@ import functools import os import pathlib +import subprocess import sys import warnings import zoneinfo @@ -17,6 +18,34 @@ greek_chars = {'sigma': u'\u03C3', 'epsilon': u'\u03B5', 'teta': u'\u03B8'} channel_order = {'Z': 0, '1': 1, 'N': 1, '2': 2, 'E': 2} +def check_gui_requirements(): + print("Checking requirements for gui") + # Define a command that tries to open a window + command = "python -c \"import tkinter; tkinter.Tk()\"" + + # Run the command and get the exit code + exit_code = os.system(command) + + # Check if tkinter gui could be created + if exit_code == 0: + #Tkinter + oktoproceed=True + else: + oktoproceed=False + print("GUI window could not be created") + + return oktoproceed + + #if sys.platform == 'linux': + # # Check if qtwayland5 is installed + # output = subprocess.run(["dpkg", "-s", "qtwayland5"], capture_output=True, text=True) + # if "Status: install ok installed" in output.stdout: + # print("qtwayland5 is already installed") + # else: + # print("qtwayland5 is not installed") + # # Install qtwayland5 + # os.system("sudo apt install qtwayland5") + #Get check mark def check_mark(incolor=False, interminal=False): """The default Windows terminal is not able to display the check mark character correctly.