Skip to content

Commit

Permalink
Corrected minor code error
Browse files Browse the repository at this point in the history
  • Loading branch information
zynapsid committed May 30, 2024
1 parent 17aa02c commit 80b1b26
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions network_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,20 +259,20 @@ def change_text_color(self):
self.canvas.draw()

def toggle_startup(self):
try:
# Assuming the executable is named network_monitor.exe and is located in the same directory as this script
exe_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'dist', 'network_monitor.exe')
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, self.REGISTRY_PATH, 0, winreg.KEY_SET_VALUE) as key:
if self.is_startup_enabled():
winreg.DeleteValue(key, self.APP_NAME)
self.startup_enabled.set(False)
print("Startup entry removed")
else:
winreg.SetValueEx(key, self.APP_NAME, 0, winreg.REG_SZ, exe_path)
self.startup_enabled.set(True)
print(f"Startup entry added: {exe_path}")
except Exception as e:
print(f"Failed to update startup setting: {e}")
try:
# Assuming the executable is named network_monitor.exe and is located in the same directory as this script
exe_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'dist', 'network_monitor.exe')
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, self.REGISTRY_PATH, 0, winreg.KEY_SET_VALUE) as key:
if self.is_startup_enabled():
winreg.DeleteValue(key, self.APP_NAME)
self.startup_enabled.set(False)
print("Startup entry removed")
else:
winreg.SetValueEx(key, self.APP_NAME, 0, winreg.REG_SZ, exe_path)
self.startup_enabled.set(True)
print(f"Startup entry added: {exe_path}")
except Exception as e:
print(f"Failed to update startup setting: {e}")

def is_startup_enabled(self):
try:
Expand Down

0 comments on commit 80b1b26

Please sign in to comment.