better cross platform support

This commit is contained in:
Prohurtz 2022-11-22 14:54:04 -08:00
parent 9c7ce288c1
commit 6ca561e6b5
2 changed files with 26 additions and 17 deletions

View File

@ -17,7 +17,8 @@ import time
import statistics import statistics
from one_euro_filter import OneEuroFilter from one_euro_filter import OneEuroFilter
from sympy import symbols, Eq, solve from sympy import symbols, Eq, solve
from winsound import PlaySound, SND_FILENAME, SND_ASYNC if sys.platform.startswith("win"):
from winsound import PlaySound, SND_FILENAME, SND_ASYNC
import scipy.signal as sp import scipy.signal as sp
@ -52,7 +53,8 @@ def run_once(f):
async def delayed_setting_change(setting, value): async def delayed_setting_change(setting, value):
await asyncio.sleep(5) await asyncio.sleep(5)
setting = value setting = value
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC) if sys.platform.startswith("win"):
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC)
def fit_rotated_ellipse_ransac( def fit_rotated_ellipse_ransac(
@ -345,7 +347,8 @@ class EyeProcessor:
self.calibration_frame_counter = None self.calibration_frame_counter = None
self.xoff = cx self.xoff = cx
self.yoff = cy self.yoff = cy
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC) if sys.platform.startswith("win"):
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC)
elif self.calibration_frame_counter != None: elif self.calibration_frame_counter != None:
self.settings.gui_recenter_eyes = False self.settings.gui_recenter_eyes = False
if cx > self.xmax: if cx > self.xmax:
@ -362,7 +365,8 @@ class EyeProcessor:
self.yoff = cy self.yoff = cy
if self.ts == 0: if self.ts == 0:
self.settings.gui_recenter_eyes = False self.settings.gui_recenter_eyes = False
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC) if sys.platform.startswith("win"):
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC)
else: else:
self.ts = self.ts - 1 self.ts = self.ts - 1
else: else:
@ -604,7 +608,8 @@ class EyeProcessor:
self.calibration_frame_counter = None self.calibration_frame_counter = None
self.xoff = cx self.xoff = cx
self.yoff = cy self.yoff = cy
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC) if sys.platform.startswith("win"):
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC)
elif self.calibration_frame_counter != None: # TODO reset calibration values on button press elif self.calibration_frame_counter != None: # TODO reset calibration values on button press
if exm > self.xmax: if exm > self.xmax:
self.xmax = exm self.xmax = exm
@ -620,7 +625,8 @@ class EyeProcessor:
self.yoff = cy self.yoff = cy
if self.ts == 0: if self.ts == 0:
self.settings.gui_recenter_eyes = False self.settings.gui_recenter_eyes = False
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC) if sys.platform.startswith("win"):
PlaySound('Audio/compleated.wav', SND_FILENAME | SND_ASYNC)
else: else:
self.ts = self.ts - 1 self.ts = self.ts - 1
else: else:

View File

@ -6,12 +6,14 @@ from settings_widget import SettingsWidget
import queue import queue
import threading import threading
import PySimpleGUI as sg import PySimpleGUI as sg
import sys
from urllib.request import urlopen from urllib.request import urlopen
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
import webbrowser import webbrowser
from win10toast_click import ToastNotifier ## REMOVE FOR LINUX COMPATIBILITY
if sys.platform.startswith("win"):
from win10toast_click import ToastNotifier
# Random environment variable to speed up webcam opening on the MSMF backend. # Random environment variable to speed up webcam opening on the MSMF backend.
# https://github.com/opencv/opencv/issues/17687 # https://github.com/opencv/opencv/issues/17687
@ -67,15 +69,16 @@ def main():
print(f"[INFO] App is up to date! {latestversion}") print(f"[INFO] App is up to date! {latestversion}")
else: else:
print(f"[INFO] You have app version {appversion} installed. Please update to {latestversion} for the newest fixes.") print(f"[INFO] You have app version {appversion} installed. Please update to {latestversion} for the newest fixes.")
toaster = ToastNotifier() ## REMOVE THIS AND NEXT 8 LINES FOR LINUX COMPATIBILITY if sys.platform.startswith("win"):
toaster.show_toast( #show windows toast toaster = ToastNotifier()
"EyeTrackVR has an update.", toaster.show_toast( #show windows toast
"Click to go to the latest version.", "EyeTrackVR has an update.",
icon_path= "Images/logo.ico", "Click to go to the latest version.",
duration=5, icon_path= "Images/logo.ico",
threaded=True, duration=5,
callback_on_click=open_url threaded=True,
) callback_on_click=open_url
)
# Check to see if we have an ROI. If not, bring up ROI finder GUI. # Check to see if we have an ROI. If not, bring up ROI finder GUI.