i had posted a previous question a bit same like this one and it got solved but i now am facing a new problem.i want to duplicate a file with the data inside it when the user clicks a button. In my previous question i figured out how to copy a file and paste it but now what happened is that the second i run my program it duplicates my file, and it doesn't even paste the data into the new file, it just creates the new file with the name i specified, but i want it to happen like when the user clicks a button then the file should be duplicated and the data should be inside it. Here is the code i used:
from tkinter import *
root=Tk()
def duplicatefunction():
f=open("prototype.txt","r")
g=open("copy.txt","w")
button1=Button(text="duplicate file", command=duplicatefunction())
button1.pack()
root.mainloop()
so what did i do wrong and how to fix it to copy the data in the files???