Open a file without getOpenFileName?
is there a way to open files without using QFileDialog.getOpenFileName
parameter? The thing is, I have a some buttons that upon clicking them, a
notepad will pop up in which you can type anything into the notepad. Then,
you can save whatever you wrote in that notepad as a file. What I want to
do is, if I click the button again, I will reopen the file that I had
previously edited via the notepad and can continue typing where I left
off. However, I don't want to use getOpenFileName. Would it be possible to
open a file without using this functionality? Below is my attempt but my
if statement keeps evaluating to be false. If anyone could help that would
be great. Thanks!
#Testing if the file already exists
if(os.path.exists("~/Desktop/" +self.fileName + ".txt")):
f = open(self.fileName + ".txt", 'r')
filedata = f.read()
self.text.setText(filedata)
f.close()
#Opens a new notepad if there wasn't a previous fileconstructed
else:
self.textBox = textBoxWindow(self.fileName)
self.textBox.show()
No comments:
Post a Comment