From eef9c35c10237d5d18e45cf5593fafaee5c1ae7f Mon Sep 17 00:00:00 2001 From: Yannik Schmidt Date: Fri, 29 Mar 2024 05:45:43 +0100 Subject: [PATCH] feat: links & steam links --- client_details.py | 33 ++++++++++++++++++++++++++++----- software.py | 13 +++++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/client_details.py b/client_details.py index 544fa0c..1c71d5d 100644 --- a/client_details.py +++ b/client_details.py @@ -109,23 +109,46 @@ def create_details_page(app, software, backswitch_function): button_frame = customtkinter.CTkFrame(info_frame, fg_color="transparent") button_frame.grid(column=0, row=6, sticky="w") elements.append(button_frame) - install_button = customtkinter.CTkButton(button_frame, text="Install", + + if software.link_only and "steam" in software.link_only: + install_text = "Open Steam" + remove_text = "Remove from Steam" + elif software.link_only: + install_text = "Open in Browser" + remove_text = "Remove Manually" + else: + install_text = "Install" + remove_text = "Remove" + + install_button = customtkinter.CTkButton(button_frame, text=install_text, command=lambda: software.install()) - remove_button = customtkinter.CTkButton(button_frame, text="Remove", - command=lambda: software.remove()) + + # add remove button # + remove_button = customtkinter.CTkButton(button_frame, text=remove_text, + command=lambda: software.remove()) + + if remove_text != "Remove": + remove_button.configure(state=tkinter.DISABLED) + remove_button.configure(fg_color="gray") + + remove_button.pack(padx=10, pady=15, anchor="sw", side="left") + # run button # run_button = customtkinter.CTkButton(button_frame, text="Run", command=lambda: software.run()) run_button.pack(padx=10, pady=15, anchor="sw", side="left") - elements.append(run_button) + + # install button # if not software.run_exe: run_button.configure(state=tkinter.DISABLED) run_button.configure(fg_color="gray") install_button.pack(padx=10, pady=15, anchor="sw", side="left") - remove_button.pack(padx=10, pady=15, anchor="sw", side="left") + + # add buttons # elements.append(install_button) + elements.append(run_button) elements.append(remove_button) # add other pictures # diff --git a/software.py b/software.py index 22ded7a..586df8b 100644 --- a/software.py +++ b/software.py @@ -5,6 +5,7 @@ import zipfile import shutil import pathlib import tqdm +import webbrowser class Software: @@ -72,6 +73,11 @@ class Software: print("Installing:", self.title, self.directory) + # handle link-only software # + if self.link_only: + webbrowser.open(self.link_only) + return + path = os.path.join(self.directory, "main_dir") try: @@ -115,5 +121,12 @@ class Software: def run(self): '''Run the configured exe for this software''' + + print(self.run_exe, self.link_only) + if self.run_exe == "steam" and "steam://" in self.link_only: + print("steam://runid/{}".format(self.link_only.split("/")[-1])) + webbrowser.open("steam://rungameid/{}".format(self.link_only.split("/")[-1])) + return + if self.run_exe: localaction.run_exe(os.path.join(self.backend.install_dir, self.title, self.run_exe)) \ No newline at end of file