[PyQt] User selected filter in QFileDialog

Phil Thompson phil at riverbankcomputing.com
Fri Jul 3 10:32:56 BST 2009


On Tue, 30 Jun 2009 08:36:04 -0700 (PDT), barmanoo
<olivier.friard at gmail.com> wrote:
> Phil Thompson-5 wrote:
>> 
>> 
>> getSaveFileName() is a static method that creates its own dialog. In
>> other
>> words the dialog the user is using isn't the same one you have created.
>> 
>> selected_filter = QString()
>> projectFileName = QFileDialog.getSaveFileName(self, 'Save the current
>> project', '',
>>         'your;;filters', selected_filter)
>> 
>> selected_filter will be updated with the selected filter (a horribly
>> unpythonic API).
>> 
>> Phil
>> 
>> 
> 
> Thank you for your reply.
> Unfortunately your suggestion do not fixed my problem...
> 
> I modified my code to:
> 
> filter=QString()
> self.projectFileName=QFileDialog.getSaveFileName(self,'Save the current
> AnnHyb project','','pyAnnHyb project (*.pyannhyb);;AnnHyb project
> (*.annhyb);;All files (*)',filter)
> print str(filter)
> 
> The filter QString variable is now always empty and no more "All files
(*)"
> 
> (?)
> 
> I am using Python 2.6.2, Qt 4.5.0 and PyQt 4.4.4 on Linux
> 
> The full code is available at
> http://www.bioinformatics.org/pyannhyb/download.php
> (file: pyannhyb.py , line 915)

The following test extracted from you code works fine for me.

Phil
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.py
Type: text/x-python
Size: 371 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090703/fb29984f/t-0001.py


More information about the PyQt mailing list