Issue
The following functions are both activated by a clicked signal of a separate QPushButton
. I want to give the user the possibility to choose a .pdf
file, do some program specific edits and save it to a user defined location.
How can I make so that the path to the .pdf
is passed to another function?
def select(self):
dir = "."
fileObjOpen = QFileDialog.getOpenFileName(self, "Select a .pdf file", dir=dir, filter="PDF Files (*.pdf)")
fileObjOpenName = fileObjOpen[0]
if (len(fileObjOpenName) > 1):
path_to_pdf = fileObjOpenName
def save(self):
dir = "."
fileObjSave = QFileDialog.getSaveFileName(self, "Where to save the new pdf file", dir=dir, filter="PDF Files (*.pdf)")
fileNameSave = fileObjSave[0]
if (len(fileNameSave) > 1):
path_to_pdf = path_to_pdf
Solution
I don't know anything about pyside
, but it seems like you're using a class since self
is the first argument to each of your functions. If that's the case, you can just set path_to_pdf
as an attribute on the class instance.
e.g.
def select(self):
#snip ...
if len(fileObjOpenName) > 1:
self.path_to_pdf = fileObjOpenName
def save(self):
#snip ...
if len(fileNameSave) > 1:
path_to_pdf = self.path_to_pdf
If I've horribly misinterpreted this, let me know and I'll delete my answer.
Answered By - mgilson
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.