Skip to content

Commit

Permalink
remove qt dependencies since using tk
Browse files Browse the repository at this point in the history
  • Loading branch information
RJbalikian committed Oct 11, 2023
1 parent 4548d8f commit 7e35320
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 19 deletions.
1 change: 0 additions & 1 deletion conda/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ dependencies:
- matplotlib
- pandas
- numpy
- pyqt5-sip
- pyproj
1 change: 0 additions & 1 deletion conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ requirements:
- matplotlib
- pandas
- numpy
- PyQt5
- pyproj

about:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions sprit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
)

from sprit.sprit_utils import(
check_gui_requirements,
checkifpath,
check_mark,
check_tsteps,
Expand Down Expand Up @@ -67,6 +68,7 @@
'HVSRData',
'HVSRBatch',
'sprit_utils',
'check_gui_requirements',
'checkifpath',
'check_mark',
'check_tsteps',
Expand Down
36 changes: 20 additions & 16 deletions sprit/sprit_gui.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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")
29 changes: 29 additions & 0 deletions sprit/sprit_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import functools
import os
import pathlib
import subprocess
import sys
import warnings
import zoneinfo
Expand All @@ -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.
Expand Down

0 comments on commit 7e35320

Please sign in to comment.