I have an interface I've created called interface.py that runs a script based on the press of a button...
def submit_action(selected_item): values = list(item_to_value[selected_item]) selected_month = month_var.get() # Check the state of the checkboxes and assign values invoice_value = "1" if invoice_var.get() else "0" loader_value = "1" if loader_var.get() else "0" # Append the checkbox values to the values list values.append(invoice_value) values.append(loader_value) values.append(selected_month) # Append the selected month if selected_item in ["Type 1", "Item 2", "Item 3"]: subprocess.run(["py", "gen_simple_management_fee.py"] + values) elif selected_item in ["Type 2", "Item 2", "Item 3"]: subprocess.run(["py", "gen_no_split_variant_2.py"] + values) elif selected_item in ["Type 3", "Item 5"]: subprocess.run(["py", "gen_fixed_split.py"] + values) elif selected_item in ["Type 4", "Item 5"]: subprocess.run(["py", "gen_daily_validations.py"] + values) elif selected_item in ["Type 5", "Type 6"]: subprocess.run(["py", "gen_variable_split.py"] + values) elif selected_item in ["Type 7", "Type 8"]: subprocess.run(["py", "gen_variable_split_variant_2.py"] + values) elif selected_item in ["Type 9", "Type 10"]: subprocess.run(["py", "gen_no_split.py"] + values) I also send a set of values across to the other scripts using a list that gets sent along with the subprocess call:
item_to_value = { "Type 1": ("Information 1", "information 2", "placeholder", "placeholder", "placeholder", "placeholder"), "Type 2": ("Information 1", "Information 2", "placeholder", "placeholder", "placeholder", "placeholder"), ... The script gets run, drawing on the subprocess information passed:
import pandas as pd import sys import os import tkinter as tk from tkinter import filedialog, Tk import customtkinter as ctk from PIL import Image corresponding_value = sys.argv[1] print(f"Running with corresponding value: {corresponding_value}") billing_project_name = sys.argv[6] selected_month = sys.argv[-1] selected_month = str(selected_month) ... When I try to package this as an .exe through pyinstaller, I either get the issue that the main interface.py file re-runs and displays another iteration of the gui, or the exe can't find the various scripts to run.
How can I make this work as an executable file? I want to avoid having to re-jig the code to run as multiprocessing instead of subprocess - unless it's the only way...
If there's a way to create an entrypoint script that runs the interface.py, then passes the correct variables and script to run, how would I do that? Any other ideas would be appreciated.
py.