Skip to content

Commit

Permalink
Update tkinterGUI.py
Browse files Browse the repository at this point in the history
Fix empty input / output fields when you cancel file dialog. Blame tkinter!
  • Loading branch information
Shtoyan committed Aug 13, 2023
1 parent 0343cff commit 0f594fe
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions kfuz2_tkinter_gui/src/tkinterGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
)
"""Default file extension list.
This gui is mainly built for KF1, so you might want to manually add file extensions of your UE2-based game."""
This gui is mainly built for KF1, so you might want to manually
add file extensions of your UE2-based game."""
DEFAULT_WIN_X: Final[int] = 750
DEFAULT_WIN_Y: Final[int] = 150
# Reference: https://coolors.co/palette/264653-2a9d8f-e9c46a-f4a261-e76f51
Expand Down Expand Up @@ -338,29 +339,29 @@ def disable_kf_checks(self, switch: BooleanVar) -> None:
"""Switch KF file check variable."""
self.no_check = switch.get()

def select_output(self, label: Label, button: Button) -> str:
def select_output(self, label: Label, button: Button) -> None:
"""Select `Output` directory from file dialog."""
self.output = filedialog.askdirectory(title="Select Output Folder")
if self.output != "":
asked_directory: str = filedialog.askdirectory(title="Select Output Folder")
if not asked_directory == "":
self.output = asked_directory
label.config(text=self.output)
label.config(background=DEFAULT_LABEL_COLOR_SELECTED)
button.config(state=NORMAL)
return self.output

def select_input(
self,
lb_input: Label,
btn_compress: Button,
btn_uncompress: Button,
) -> str:
) -> None:
"""Select `Input` directory from file dialog."""
self.input = filedialog.askdirectory(title="Select Input Folder")
if self.input != "":
asked_directory: str = filedialog.askdirectory(title="Select Input Folder")
if not asked_directory == "":
self.input = asked_directory
lb_input.config(text=self.input)
lb_input.config(background=DEFAULT_LABEL_COLOR_SELECTED)
btn_compress.config(state=NORMAL)
btn_uncompress.config(state=NORMAL)
return self.input

def open_output(self) -> None:
"""Open `Output` directory in file explorer."""
Expand Down Expand Up @@ -591,7 +592,10 @@ def display_pbar(self) -> None:
self.on_close()
messagebox.showwarning(
title="No files to process!",
message=f'There are no matching files in "{self.parent.input}". Check your extension list / select proper directory.',
message=(
f'There are no matching files in "{self.parent.input}". '
"Check your extension list / select proper directory."
),
)


Expand Down

0 comments on commit 0f594fe

Please sign in to comment.