From cf99c58195f93be619e2cb4af6d87f86edb9e264 Mon Sep 17 00:00:00 2001 From: DJSchaffner Date: Thu, 1 Sep 2022 22:48:22 +0200 Subject: [PATCH] Made patch selector and text box scrollable --- src/logic.py | 2 +- src/main.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/logic.py b/src/logic.py index cd7fc99..e714f70 100644 --- a/src/logic.py +++ b/src/logic.py @@ -120,7 +120,7 @@ def restore(self): # Copy backed up files to game path again try: - print("Restoring backup") + print("Restoring backup...") shutil.copytree(self.backup_dir.absolute(), self.game_dir.absolute(), dirs_exist_ok=True) print("Finished restoring backup") print("DONE!") diff --git a/src/main.py b/src/main.py index c02e110..de81e16 100644 --- a/src/main.py +++ b/src/main.py @@ -4,6 +4,7 @@ import time import tkinter as tk +import tkinter.scrolledtext as scrolledtext import tkinter.ttk as ttk import tkinter.filedialog @@ -48,10 +49,11 @@ def on_closing(): patch_titles = [f"{p['version']} - {time.strftime('%d/%m/%Y', time.gmtime(p['date']))}" for p in self.patch_list] - self.lbl_select_patch = ttk.Label(master=self.upper_frame, text="Version") + self.lbl_select_patch = ttk.Label(master=self.upper_frame, text="Target version") self.lbl_select_patch.grid(row=0, column=0, sticky="e") - self.opt_select_patch = ttk.OptionMenu(self.upper_frame, self.selected_patch_title, patch_titles[0], *[p for p in patch_titles]) - self.opt_select_patch.grid(row=0, column=1, sticky="w") + self.cmb_select_patch = ttk.Combobox(self.upper_frame, state="readonly", textvariable=self.selected_patch_title, values=[p for p in patch_titles]) + self.cmb_select_patch.current(0) # Set default value + self.cmb_select_patch.grid(row=0, column=1, sticky="w") self.btn_patch = ttk.Button(master=self.upper_frame, text="Patch", command=self._patch) self.btn_patch.grid(row=0, column=5, sticky="nesw") @@ -72,7 +74,7 @@ def on_closing(): self.ent_password = ttk.Entry(master=self.upper_frame, show="*") self.ent_password.grid(row=2, column=3, sticky="nesw") - self.text_box = tk.Text(master=self.lower_frame, state="disabled") + self.text_box = scrolledtext.ScrolledText(master=self.lower_frame, state="disabled") self.text_box.pack(expand=True, fill="both") # Redirect stdout to the text box @@ -128,7 +130,7 @@ def work(): def _disable_input(self): """Disables User input for certain Buttons / Entries. """ - self.opt_select_patch.config(state="disabled") + self.cmb_select_patch.config(state="disabled") self.btn_patch.config(state="disabled") self.btn_restore.config(state="disabled") self.btn_game_dir.config(state="disabled") @@ -138,7 +140,7 @@ def _disable_input(self): def _enable_input(self): """Enables User input for certain Buttons / Entries. """ - self.opt_select_patch.config(state="enabled") + self.cmb_select_patch.config(state="readonly") self.btn_patch.config(state="enabled") self.btn_restore.config(state="enabled") self.btn_game_dir.config(state="enabled")