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

SM sunithanc at gmail.com
Mon May 27 16:22:23 CEST 2013


Yes, the following works.
path = QtGui.QFileDialog.getOpenFileName()

Thanks!


On Mon, May 27, 2013 at 9:45 AM, Matthew Ngaha <chigga101 at gmail.com> wrote:

> On Mon, May 27, 2013 at 2:14 PM, SM <sunithanc at gmail.com> wrote:
>
> >But then I also had to use self.fileDialog from within the function. Not
> > sure how I could avoid using fileDialog.
> >
> > Thanks.
>
> No problem. to do it without the instance variable, you access its
> method directly. so replace:
>
> path = self.fileDialog.getOpenFileName()
>
> with
>
> path = QFileDialog.getOpenFileName(self)
>
> which is basically the same thing except you're going to the method
> directly instead of creating a class instance. The self argument may
> or may not be needed, its been a while since ive used Qt.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130527/07c03176/attachment.html>


More information about the Tutor mailing list