feat: only enable run button if installed

This commit is contained in:
2024-06-08 16:30:20 +02:00
parent 8c2057d8ac
commit 05d2833344
2 changed files with 16 additions and 9 deletions

View File

@@ -2,7 +2,7 @@ import PIL
import tkinter
import customtkinter
import imagetools
import os
def show_large_picture(app, path):
'''Show a full-window version of the clicked picture'''
@@ -150,9 +150,10 @@ def create_details_page(app, software, backswitch_function):
run_button = customtkinter.CTkButton(button_frame, text="Run",
command=lambda: software.run())
run_button.pack(padx=10, pady=15, anchor="sw", side="left")
software.run_button = run_button
# install button #
if not software.run_exe:
if not software.run_exe or not os.path.isfile(software.run_exe):
run_button.configure(state=tkinter.DISABLED)
run_button.configure(fg_color="gray")

View File

@@ -1,4 +1,5 @@
import yaml
import tkinter
import os
import localaction
import zipfile
@@ -15,6 +16,7 @@ class Software:
self.meta_file = meta_file
self.directory = os.path.dirname(meta_file)
self.backend = backend
self.run_button = None
print("Software Directory:", self.directory)
self.cache_dir = backend.cache_dir or os.path.join("cache", self.directory.lstrip("/").lstrip("\\"))
@@ -155,6 +157,10 @@ class Software:
shutil.copy(tmp, dest_dir)
self.progress_bar_wrapper.set_text(text="")
if self.run_button:
self.run_button.configure(state=tkinter.NORMAL)
self.run_button.configure(fg_color="green")
def run(self):
'''Run the configured exe for this software'''