Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
Fixed Bug for save path,
Fixed bug for missing languages.txt on initial launch
Disabled Conversion button when Converting
  • Loading branch information
niefia committed Mar 8, 2023
1 parent 8ad916d commit e9d8999
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions uictk.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,20 @@
import sys
from PIL import Image

if not os.path.exists('language.txt'):
with open('language.txt', 'w') as f:
f.write('')

# All CustomTkinter Code

if getattr(sys, 'frozen', False):
# If the application is run as a bundle, use the bundle directory as the current directory
current_dir = os.path.dirname(sys.executable)
else:
# If the application is run as a script, use the directory containing the script as the current directory
current_dir = os.path.dirname(os.path.abspath(__file__))


# All CustomTkinter Code
class App(customtkinter.CTk):


Expand Down Expand Up @@ -159,8 +169,8 @@ def update_language(option):
f.write(LANGUAGE)

def run_converter():
self.Conversion_button.configure(state="disabled")
self.Conversion_progress_bar.set(0.1)
#self.get_dirs_button.configure(state="disabled")
modpath = self.CK3_Mod_Path_Entry.get()
mapfilldir = self.CK3_Map_Filler_Tool_Path_Entry.get()
installdir = self.CK3_Game_Path_Entry.get()
Expand All @@ -179,6 +189,11 @@ def run_converter():
scaling_factor = 50
scaling_factor = int(scaling_factor)

if generate_characters == "Generate Characters":
CharGen_response = "yes"
else:
CharGen_response = "no"

gamedir = os.path.join(installdir, 'game')
output_dir = os.path.join(modpath, modname)
try:
Expand Down Expand Up @@ -216,6 +231,8 @@ def run_converter():
sys.exit(1) # exit with an error code

messagebox.showinfo("Conversion Complete", "The conversion process is complete!")
self.Conversion_button.configure(state="normal")



print(installdir,modpath,mapfilldir,scaling_factor,scaling_method_str,modname,generate_characters,CharGen_response,scaling_method_str) # or return game_path
Expand Down Expand Up @@ -272,12 +289,12 @@ def optionmenu_callback(choice):
# Saves the paths to a file

def save_paths():
Entry1_value = self.CK3_Mod_Path_Entry.get()
Entry1_value = self.CK3_Game_Path_Entry.get()
Entry2_value = self.CK3_Mod_Path_Entry.get()
Entry3_value = self.CK3_Map_Filler_Tool_Path_Entry.get()

# Get the filename to save the data
current_dir = os.path.dirname(os.path.abspath(__file__))
#current_dir = os.path.dirname(os.path.abspath(__file__))
filename = filedialog.asksaveasfilename(initialdir=current_dir, defaultextension='.txt', initialfile='paths.txt')
if filename:
# Save the values to the file
Expand All @@ -291,8 +308,9 @@ def save_paths():
# Loads the paths from a file
def load_paths():
# Get the filename to load the data
current_dir = os.path.dirname(os.path.abspath(__file__))
#current_dir = os.path.dirname(os.path.abspath(__file__))
filename = filedialog.askopenfilename(initialdir=current_dir, initialfile='paths.txt')

if filename:
# Read the saved values from the file
with open(filename, 'r') as f:
Expand Down

0 comments on commit e9d8999

Please sign in to comment.