I my python GUI, I have created a questionaire. In this it allows me to ask questions and then save them to a text file. i have saved them to a text file using a variable, so each file is different. E.G.
name = james (the file will be called james)
or...
name = Charlie (the file will be called Charlie)
I am able to write and save to the text file. What I need to b able to do is find a way to open the text file by using a variable. this will allow me to input a name, such as "James" and I can open the file called James.
This is the code I have at the moment.
name = entry.get()
# this collects the name from an entry box.
newfile = (name.txt,"r")
# name is the variable I am using.
loaded = (newfile.read())
# this would hopefully put the file text into a variable
textbox.delete(0.0, END)
# this will clear the text box
textbox.insert(END, loaded)
# this put the text from the file (in loaded) into the text box
Is there a way to allow me to do this? I hope this makes sense. Thank you all who help.