I was creating a program to transfer user inputs over discord to do this you needed 2 discord bots so i made a setup file for the tokens this setup file works fine it opens a tk window in which it asked for the data but then it would give me permission error: PermissionError: [Errno 13] Permission denied: 'vars.py'
here is my code i am confused in the past when writing to files (in replit) i didnt encounter any permision error’s.
import tkinter as tk
from tkinter import ttk
from tkinter import messagebox
def write_to_file(file_path, text):
with open(file_path, 'w') as file:
file.write(text)
def submit():
vc_id = vc_id_entry.get()
sender_token = sender_token_entry.get()
receiver_token = receiver_token_entry.get()
write_to_file("vars.py", f"vc_id = {vc_id}ns_token = "{sender_token}"nr_token = "{receiver_token}"nsetup = True")
messagebox.showinfo("Setup Done", "You may now close the window")
# Create main window
root = tk.Tk()
root.title("Setup")
# Create labels and entry boxes
vc_id_label = ttk.Label(root, text="VC ID:")
vc_id_label.grid(row=0, column=0, padx=10, pady=10, sticky=tk.W)
vc_id_entry = ttk.Entry(root, width=40)
vc_id_entry.grid(row=0, column=1, padx=10, pady=10)
sender_token_label = ttk.Label(root, text="Sender Token:")
sender_token_label.grid(row=1, column=0, padx=10, pady=10, sticky=tk.W)
sender_token_entry = ttk.Entry(root, width=40)
sender_token_entry.grid(row=1, column=1, padx=10, pady=10)
receiver_token_label = ttk.Label(root, text="Receiver Token:")
receiver_token_label.grid(row=2, column=0, padx=10, pady=10, sticky=tk.W)
receiver_token_entry = ttk.Entry(root, width=40)
receiver_token_entry.grid(row=2, column=1, padx=10, pady=10)
# Submit button
submit_button = ttk.Button(root, text="Submit", command=submit)
submit_button.grid(row=3, columnspan=2, pady=10)
# Start GUI
root.mainloop()
I tryed to fix it by using chatgpt but it just gave me a ton of bs. I was expecting it to run and fill in the variables it asked for into the vars.py file which would be accsesed by the main file to run the discord bots.