[Tutor] Fwd: QT Python: How to re-use the return value of fileDialog.openFileName() ?

Matthew Ngaha chigga101 at gmail.com
Mon May 27 12:01:31 CEST 2013


Sorry for the forward, i forgot to reply to tutor

On Mon, May 27, 2013 at 3:53 AM, Sunitha Misra <sunithanc at gmail.com> wrote:

> self.fileDialog = QtGui.QFileDialog()
>
> QtCore.QObject.connect(self.toolButton,
> QtCore.SIGNAL(_fromUtf8("clicked()")), self.fileDialog.getOpenFileName)
>

i think the way youre doing it won't allow you to get the filename as
you are calling it through a signal.

Things you can do:

1) dont use self.fileDialog.getOpenFileName as a slot like you are
doing. Create a function and call it when the toolbar's button is
clicked, then in that function assign the filename to the return value
of self.fileDialog.getOpenFileName.

2) if the only thing your self.fileDialog is doing is responding to
the toolbar's button, don't create it at all. do what i said in #1 and
assign a filename variable to the full method of the dialog. What im
saying is there might be no need to create the self.fileDialog
instance variable at all.


More information about the Tutor mailing list