Skip to content

Commit

Permalink
Made patch selector and text box scrollable
Browse files Browse the repository at this point in the history
  • Loading branch information
jwlkns committed Sep 1, 2022
1 parent 5f12eb3 commit cf99c58
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
Expand Down
14 changes: 8 additions & 6 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import time

import tkinter as tk
import tkinter.scrolledtext as scrolledtext
import tkinter.ttk as ttk
import tkinter.filedialog

Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down

0 comments on commit cf99c58

Please sign in to comment.