add toggle for update check

This commit is contained in:
Prohurtz 2023-01-22 19:17:37 -06:00
parent f492e3fdab
commit 2573d04ce8
3 changed files with 42 additions and 28 deletions

View File

@ -47,6 +47,7 @@ class EyeTrackSettingsConfig(BaseModel):
gui_BLOBP: int = 4 gui_BLOBP: int = 4
gui_skip_autoradius: bool = True gui_skip_autoradius: bool = True
gui_thresh_add: int = 20 gui_thresh_add: int = 20
gui_update_check: bool = True
class EyeTrackConfig(BaseModel): class EyeTrackConfig(BaseModel):
version: int = 1 version: int = 1

View File

@ -50,36 +50,36 @@ def main():
# Check to see if we can connect to our video source first. If not, bring up camera finding # Check to see if we can connect to our video source first. If not, bring up camera finding
# dialog. # dialog.
if config.settings.gui_update_check:
print("\033[95m[INFO] Checking for updates...\033[0m")
url = "https://raw.githubusercontent.com/RedHawk989/EyeTrackVR-Installer/master/Version-Data/Version_Num.txt"
html = urlopen(url).read()
soup = BeautifulSoup(html, features="html.parser")
for script in soup(["script", "style"]):
script.extract()
text = soup.get_text()
print("\033[95m[INFO] Checking for updates...\033[0m") # break into lines and remove leading and trailing space on each
url = "https://raw.githubusercontent.com/RedHawk989/EyeTrackVR-Installer/master/Version-Data/Version_Num.txt" lines = (line.strip() for line in text.splitlines())
html = urlopen(url).read() # break multi-headlines into a line each
soup = BeautifulSoup(html, features="html.parser") chunks = (phrase.strip() for line in lines for phrase in line.split(" "))
for script in soup(["script", "style"]): # drop blank lines
script.extract() latestversion = '\n'.join(chunk for chunk in chunks if chunk)
text = soup.get_text()
# break into lines and remove leading and trailing space on each if appversion == latestversion: # If what we scraped and hardcoded versions are same, assume we are up to date.
lines = (line.strip() for line in text.splitlines()) print(f"\033[92m[INFO] App is up to date! [{latestversion}]\033[0m")
# break multi-headlines into a line each else:
chunks = (phrase.strip() for line in lines for phrase in line.split(" ")) print(f"\033[93m[INFO] You have app version [{appversion}] installed. Please update to [{latestversion}] for the newest features.\033[0m")
# drop blank lines if sys.platform.startswith("win"):
latestversion = '\n'.join(chunk for chunk in chunks if chunk) toaster = ToastNotifier()
toaster.show_toast( #show windows toast
if appversion == latestversion: # If what we scraped and hardcoded versions are same, assume we are up to date. "EyeTrackVR has an update.",
print(f"\033[92m[INFO] App is up to date! [{latestversion}]\033[0m") "Click to go to the latest version.",
else: icon_path= "Images/logo.ico",
print(f"\033[93m[INFO] You have app version [{appversion}] installed. Please update to [{latestversion}] for the newest features.\033[0m") duration=5,
if sys.platform.startswith("win"): threaded=True,
toaster = ToastNotifier() callback_on_click=open_url
toaster.show_toast( #show windows toast )
"EyeTrackVR has an update.",
"Click to go to the latest version.",
icon_path= "Images/logo.ico",
duration=5,
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.

View File

@ -39,6 +39,7 @@ class SettingsWidget:
self.gui_BLOBP = f"-BLOBP{widget_id}-" self.gui_BLOBP = f"-BLOBP{widget_id}-"
self.gui_thresh_add = f"-THRESHADD{widget_id}-" self.gui_thresh_add = f"-THRESHADD{widget_id}-"
self.gui_update_check = f"-UPDATECHECK{widget_id}-"
self.gui_threshold_slider = f"-BLOBTHRESHOLD{widget_id}-" self.gui_threshold_slider = f"-BLOBTHRESHOLD{widget_id}-"
self.main_config = main_config self.main_config = main_config
self.config = main_config.settings self.config = main_config.settings
@ -88,6 +89,15 @@ class SettingsWidget:
tooltip = "Only send a blink to VRC if both eyes are closed.", tooltip = "Only send a blink to VRC if both eyes are closed.",
), ),
], ],
[sg.Checkbox(
"Check For Updates",
default=self.config.gui_update_check,
key=self.gui_update_check,
background_color='#424042',
tooltip = "Toggle update check on launch.",
),
],
[ [
sg.Text("Tracking Algorithim Settings:", background_color='#242224'), sg.Text("Tracking Algorithim Settings:", background_color='#242224'),
@ -420,6 +430,9 @@ class SettingsWidget:
self.config.gui_skip_autoradius = values[self.gui_skip_autoradius] self.config.gui_skip_autoradius = values[self.gui_skip_autoradius]
changed = True changed = True
if self.config.gui_update_check != values[self.gui_update_check]:
self.config.gui_update_check = values[self.gui_update_check]
changed = True
if self.config.gui_BLINK != values[self.gui_BLINK]: if self.config.gui_BLINK != values[self.gui_BLINK]:
self.config.gui_BLINK = values[self.gui_BLINK] self.config.gui_BLINK = values[self.gui_BLINK]