diff --git a/client.py b/client.py index b825ec3..16aef78 100644 --- a/client.py +++ b/client.py @@ -9,12 +9,13 @@ customtkinter.set_default_color_theme("blue") app = customtkinter.CTk() -app.geometry("720x780") +app.geometry("1000x750") last_geometry = app.winfo_geometry() app.title("Test") app.update() buttons = [] +details_elements = [] def create_navbar(): '''Create basic navigation bar''' @@ -40,6 +41,8 @@ def switch_to_game_details(software): def load_main(): '''Load the main page overview''' + app.title("Lan Vault: Overview") + # create tiles from meta files # for software in db.find_all_metadata(): print(software.title) @@ -59,6 +62,7 @@ def destroy_main(): def load_details(app, software): '''Load the details page for a software''' + app.title("Lan Vault: {}".format(software.title)) details_elements = client_details.create_details_page(app, software) def create_main_window_tile(software): diff --git a/client_details.py b/client_details.py index a44a647..48f5fe4 100644 --- a/client_details.py +++ b/client_details.py @@ -16,52 +16,64 @@ def create_details_page(app, software): img = PIL.ImageTk.PhotoImage(img) # thumbnail image # - thumbnail_image = customtkinter.CTkButton(app, text="", image=img, width=200, height=300, + thumbnail_image = customtkinter.CTkButton(app, text="", image=img, width=500, height=700, command=lambda: show_large_picture(app, path)) - thumbnail_image.pack() + thumbnail_image.grid(column=0, row=0, padx=10, pady=10) elements.append(thumbnail_image) + # fonts # + title_font = customtkinter.CTkFont(family="Helvetica", size=29, weight="bold") + genre_font = customtkinter.CTkFont(family="Helvetica", size=14, slant="italic") + + # info box # + info_frame = customtkinter.CTkFrame(app) + info_frame.grid(column=1, row=0, sticky="ns", padx=10, pady=10) + # title # - title = customtkinter.CTkLabel(app, textvariable=software.title) - title.pack() + title = customtkinter.CTkLabel(info_frame, text=software.title, font=title_font) + title.pack(anchor="w", side="top", padx=20, pady=10) + print("Title:", software.title) elements.append(title) # genre # - genre = customtkinter.CTkLabel(app, textvariable=software.genre) - genre.pack() + genre_text = "Genre: {}".format(software.genre) + genre = customtkinter.CTkLabel(info_frame, text=genre_text, padx=20, font=genre_font) + genre.pack(anchor="w", side="top") elements.append(genre) # description # - description = customtkinter.CTkTextbox(app) + description = customtkinter.CTkTextbox(info_frame, width=400, height=200) description.insert("0.0", software.description) - description.pack() + description.pack(anchor="w", side="top", fill="both", padx=20, pady=15) elements.append(description) # dependencies # - dependencies = customtkinter.CTkTextbox(app) - dependencies.insert("0.0", str(software.dependencies)) - description.pack() - elements.append(description) + dependencies_text = ",".join(software.dependencies) + dependencies = customtkinter.CTkLabel(info_frame, text=dependencies_text) + dependencies.pack(anchor="w", side="top", padx=20) + elements.append(dependencies) # buttons # - install_button = customtkinter.CTkButton(app, text="Install", + install_button = customtkinter.CTkButton(info_frame, text="Install", command=lambda: software.install(software)) - remove_button = customtkinter.CTkButton(app, text="Remove", + remove_button = customtkinter.CTkButton(info_frame, text="Remove", command=lambda: software.remove(software)) - install_button.pack() - remove_button.pack() + install_button.pack(padx=20, pady=30, anchor="sw", side="left") + remove_button.pack(padx=20, pady=30, anchor="sw", side="left") elements.append(install_button) elements.append(remove_button) # add other pictures # + i = 0 for path in software.pictures[1:]: img = PIL.Image.open(software.get_thumbnail()) img = img.resize((200, 300)) img = PIL.ImageTk.PhotoImage(img) extra_pic_button = customtkinter.CTkButton(app, text="", image=img, width=200, height=300, command=lambda: show_large_picture(app, path)) - extra_pic_button.pack() + extra_pic_button.grid(padx=10, pady=10, row=0, column=i) elements.append(extra_pic_button) + i += 1 return elements diff --git a/data_backend.py b/data_backend.py index ad518c1..fbc5abf 100644 --- a/data_backend.py +++ b/data_backend.py @@ -30,11 +30,14 @@ class DataBackend: class LocalFS(DataBackend): def get(self, path): + fullpath = os.path.join(self.remote_root_dir, path) with open(fullpath, "rb") as f: target = os.path.join(self.cache_dir, os.path.basename(path)) with open(target, "wb") as ft: ft.write(f.read()) + + return target def list(self, path): fullpath = os.path.join(self.remote_root_dir, path) diff --git a/example_software_root/FreeDink/meta.yaml b/example_software_root/FreeDink/meta.yaml index b229269..8f99bd3 100644 --- a/example_software_root/FreeDink/meta.yaml +++ b/example_software_root/FreeDink/meta.yaml @@ -1,7 +1,7 @@ genre: RPG title: GNU FreeDink -description: | - Free GNU RPG from 1993. +description: > + Free GNU RPG from 1993. The game centers on Dink, a pig farmer-turned-hero who embarks on various quests throughout his world. The game features isometric, Diablo-like gameplay,[3] including weapons, items, and magic. The game has a satirical off-color slant, including everything from a fiercely abusive uncle diff --git a/software.py b/software.py index 7774533..166f32e 100644 --- a/software.py +++ b/software.py @@ -1,22 +1,24 @@ import yaml import os +import localaction class Software: - def __init__(self, directory): + def __init__(self, directory, backend): if os.path.isfile(directory) and directory.endswith("meta.yaml"): directory = os.path.dirname(directory) self.directory = directory self._load_from_yaml() + self.backend = backend def _load_from_yaml(self): fullpath = os.path.join(self.directory, "meta.yaml") self.info_file = fullpath with open(fullpath) as f: - meta = yaml.load(f) + meta = yaml.safe_load(f) self.title = meta.get("title") self.genre = meta.get("genre") @@ -32,5 +34,23 @@ class Software: def get_thumbnail(self): return self.pictures[0] + + def _extract_to_target(self, cache_src, target): + '''Extract a cached, downloaded zip to the target location''' + def install(self): + '''Install this software from the backend''' + local_file = self.backend.get_exe_or_data(): + + if local_file.endswith(".exe"): + localaction.run_exe(local_file) + elif local_file.endswith(".zip"): + _extract_to_target(INSTALL_DIR) + + # download registry + # install registry + # TODO dependencies # + # download gamefiles + # install gamefiles + \ No newline at end of file