import os import tkinter as tk from tkinter import filedialog, Text get_path = os.getcwd()[:-22] root = tk.Tk() focuses = get_path+r"common\national_focus\TNO_burgundy_shared.txt" focus_list = [] def run_app(): starting_focus = entry1.get() end_focus = entry2.get() starting_focus_found = False for line in open(focuses, "r").readlines(): if starting_focus_found == False: if starting_focus in line: starting_focus_found = True else: continue if " id = " in line and not " " in line: focus_list.append(line[6:-1]) if end_focus in line: break for focus in focus_list: if "blankfocus" not in focus: print(focus) focus_name = focus.replace("_", " ")[4:].title() focus2 = focus[4:].title() with open(get_path+r"common\scripted_localisation\TNO_Burgundy_scripted_localisation.txt", "a") as scripted_loc: scripted_loc.write("\ndefined_text = {") scripted_loc.write("\n name = GetBRGFocus"+focus2) scripted_loc.write("\n text = {") scripted_loc.write("\n trigger = {") scripted_loc.write("\n OR = {") scripted_loc.write("\n BRG = {") scripted_loc.write("\n is_ai = no") scripted_loc.write("\n }") scripted_loc.write("\n AND = {") scripted_loc.write("\n BRG = {") scripted_loc.write("\n is_ai = yes") scripted_loc.write("\n }") scripted_loc.write("\n NOT = {") scripted_loc.write("\n has_global_flag = BRG_schattenstaat") scripted_loc.write("\n }") scripted_loc.write("\n }") scripted_loc.write("\n }") scripted_loc.write("\n }") scripted_loc.write("\n localization_key = "+focus+"_text") scripted_loc.write("\n }") scripted_loc.write("\n text = {") scripted_loc.write("\n trigger = {") scripted_loc.write("\n BRG = {") scripted_loc.write("\n is_ai = yes") scripted_loc.write("\n has_global_flag = BRG_schattenstaat") scripted_loc.write("\n }")b scripted_loc.write("\n }") scripted_loc.write("\n localization_key = BRG_redacted") scripted_loc.write("\n }") scripted_loc.write("\n}\n") with open(get_path+r"localisation\TNO_Burgundy_l_english.yml", "a") as loc: loc.write(f"\n\n{focus}:0 \"[Root.GetBRGFocus{focus2}]\"\n") loc.write(f"{focus}_text:0 \"{focus_name}\"\n") loc.write(f"{focus}_desc:0 \"\"") canvas = tk.Canvas(root, height=310, width=200) canvas.pack() entry1 = tk.Entry(root) canvas.create_window(100, 140, window=entry1) entry2 = tk.Entry(root) canvas.create_window(100, 190, window=entry2) entry1text = tk.Label(root, text="Starting Focus ID to Loc:", wraplength=170).place(x=45, y=110) entry2text = tk.Label(root, text="Final Focus ID to Loc:", wraplength=170).place(x=45, y=160) run_application = tk.Button(root, text=" Run Program ", fg="black", command=run_app).place(x=52, y=30) root.title("Burgundy Scripted Loc Generator") root.mainloop()