Reputation: 109
I am having trouble, trying to get my open button to open a text file. I want it to open the text file into the not pad, when I click the open button. If some one could help me or tell me what I am doing wrong, I would appreciate it.
def _open(self):
open("../Address.txt","r").close()
with open("../Address.txt", "a") as file:
self._outputArea.insert("1.0", file.read)
file.read()
Upvotes: 0
Views: 1008
Reputation: 8979
with
line.file
as a variable name, it's also a type.read
.'a'
is a flag for appending a file, use 'r'
(for read) instead.Try something like:
def _open(self):
with open("../Address.txt", "r") as the_file:
self._outputArea.insert("1.0", the_file.read())
Upvotes: 1