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_skip_autoradius: bool = True
gui_thresh_add: int = 20
gui_update_check: bool = True
class EyeTrackConfig(BaseModel):
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
# dialog.
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()
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()
# break into lines and remove leading and trailing space on each
lines = (line.strip() for line in text.splitlines())
# break multi-headlines into a line each
chunks = (phrase.strip() for line in lines for phrase in line.split(" "))
# drop blank lines
latestversion = '\n'.join(chunk for chunk in chunks if chunk)
# break into lines and remove leading and trailing space on each
lines = (line.strip() for line in text.splitlines())
# break multi-headlines into a line each
chunks = (phrase.strip() for line in lines for phrase in line.split(" "))
# drop blank lines
latestversion = '\n'.join(chunk for chunk in chunks if chunk)
if appversion == latestversion: # If what we scraped and hardcoded versions are same, assume we are up to date.
print(f"\033[92m[INFO] App is up to date! [{latestversion}]\033[0m")
else:
print(f"\033[93m[INFO] You have app version [{appversion}] installed. Please update to [{latestversion}] for the newest features.\033[0m")
if sys.platform.startswith("win"):
toaster = ToastNotifier()
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
)
if appversion == latestversion: # If what we scraped and hardcoded versions are same, assume we are up to date.
print(f"\033[92m[INFO] App is up to date! [{latestversion}]\033[0m")
else:
print(f"\033[93m[INFO] You have app version [{appversion}] installed. Please update to [{latestversion}] for the newest features.\033[0m")
if sys.platform.startswith("win"):
toaster = ToastNotifier()
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.

View File

@ -39,6 +39,7 @@ class SettingsWidget:
self.gui_BLOBP = f"-BLOBP{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.main_config = main_config
self.config = main_config.settings
@ -88,6 +89,15 @@ class SettingsWidget:
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'),
@ -420,6 +430,9 @@ class SettingsWidget:
self.config.gui_skip_autoradius = values[self.gui_skip_autoradius]
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]:
self.config.gui_BLINK = values[self.gui_BLINK]