Improved enums and error handling
This commit is contained in:
@@ -11,13 +11,13 @@ from modules.utils import configGet, get_string_mode
|
||||
|
||||
def try_connecting(master: Any):
|
||||
try:
|
||||
if requests.get(configGet("address")+"/apikey", headers={"apikey": configGet("apikey")}, verify=not configGet("allow_self_signed")).status_code != 200:
|
||||
if requests.get(configGet("address")+"/apikey", headers={"apikey": configGet("apikey")}, verify=not configGet("allow_self_signed")).status_code == 403:
|
||||
messagebox.showerror(title="Authentication error", message="Your API key seems to be invalid.")
|
||||
return
|
||||
# messagebox.showinfo(title="Connection succeeded", message="Server is reachable, apikey is valid, so your client is now ready to be used!")
|
||||
master.destroy_everything()
|
||||
except:
|
||||
messagebox.showerror(title="Configuration error", message="Your client configuration is incorrect.")
|
||||
messagebox.showerror(title="Connection error", message="Server is not reachable or your client configuration is incorrect. Please check your network connection and client configuration.")
|
||||
# master.destroy_everything()
|
||||
|
||||
|
||||
|
@@ -4,6 +4,7 @@ from tkinter import N, NSEW, S, W, E, END, IntVar, StringVar, filedialog, messag
|
||||
|
||||
from ttkthemes import ThemedTk
|
||||
from classes.custom.themed_frame import ThemedFrame
|
||||
from classes.enums import SavesPreference, SavesPreferenceButton, Theme
|
||||
from modules.theme_titlebar import theme_title_bar
|
||||
|
||||
from modules.utils import configGet, configSet, get_string_mode, use_dark_mode
|
||||
@@ -92,10 +93,10 @@ class FrameSettings(ThemedFrame):
|
||||
self.saves_preference_label = ttk.Label(self, text="Saves preference:")
|
||||
self.saves_preference_label.grid(column=0, row=4, sticky=W, padx=9, pady=9)
|
||||
|
||||
self.default_preference = "Latest upload " if configGet("prefer_saves") == "latest upload" else "Latest progress "
|
||||
self.default_preference = SavesPreferenceButton.LATEST_UPLOAD.value if configGet("prefer_saves") == SavesPreference.LATEST_UPLOAD.value else SavesPreferenceButton.LATEST_PROGRESS.value
|
||||
|
||||
self.chosen_preference = StringVar()
|
||||
self.preferences = ("Latest upload ", "Latest progress ")
|
||||
self.preferences = (SavesPreferenceButton.LATEST_UPLOAD.value, SavesPreferenceButton.LATEST_PROGRESS.value)
|
||||
self.saves_preference_button = ttk.OptionMenu(self, self.chosen_preference, self.default_preference, *self.preferences, direction="below")
|
||||
self.saves_preference_button.grid(column=1, row=4, sticky=W, padx=9, pady=9)
|
||||
# ================
|
||||
@@ -127,10 +128,13 @@ class FrameSettings(ThemedFrame):
|
||||
|
||||
def change_theme(self, *args):
|
||||
|
||||
if self.chosen_theme.get().strip().lower() == "auto":
|
||||
self.chosen_theme_real = "dark" if use_dark_mode(no_config=True) is True else "light"
|
||||
if self.chosen_theme.get().strip().lower() == Theme.AUTO.value:
|
||||
self.chosen_theme_real = Theme.DARK if use_dark_mode(no_config=True) is True else Theme.LIGHT
|
||||
else:
|
||||
self.chosen_theme_real = self.chosen_theme.get().strip().lower()
|
||||
if self.chosen_theme.get().strip().lower() == Theme.LIGHT.value:
|
||||
self.chosen_theme_real = Theme.LIGHT
|
||||
else:
|
||||
self.chosen_theme_real = Theme.DARK
|
||||
theme_title_bar(self.master, self.chosen_theme_real)
|
||||
|
||||
def select_location(self, entry: ttk.Entry):
|
||||
|
Reference in New Issue
Block a user