On 4/21/06, <b class="gmail_sendername">Alexander Borghgraef</b> <<a href="mailto:alexander.borghgraef.rma@gmail.com">alexander.borghgraef.rma@gmail.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="direction: ltr;">Hi all,<br>
<br>
I'm trying to read in files in my PyQt app, so naturally I'm using QFileDialog. The way I read<br>
the Qt docs, you can use multiple file type filters in the dialog by using ;; as a separator between<br>
the type lists in the filter string. Like this:<br>
<br>
def fileOpen(self):<br>
filename =
QFileDialog.getOpenFileNames("", "JPG (*.jpg);;PGM (*.pgm)"), self,
"Read file", "Read file")<br>
...<br>
<br>
I've found several examples on the net (C++ though, not Python) which do this, so I figured it should work,<br>
but what I got instead of three filters: "JPG (*.jpg)", "PGM (*.pgm)", and the default "All Files (*)", were three filters<br>
of which two were identical instances "JPG (*.jpg);;PGM (*.pgm)", and the third the default one. Any idea what<br>
the problem is here? I'm using Qt 3.3.3 and PyQt 3.13. </div></blockquote><div><br>
Never mind, found it. For some bizarre reason getOpenFileName and getOpenFileNames have a reversed order for<br>
the path and filter arguments. So for it to work, the code should be:<br>
<br>
def fileOpen(self):<br>
filename =
QFileDialog.getOpenFileName("", "JPG (*.jpg);;PGM (*.pgm)"), self,
"Read file", "Read file")<br>
<br>
if you want to read a single file, or if you want several, it should be:<br>
<br>
def fileOpen(self):<br>
filename =
QFileDialog.getOpenFileNames( "JPG (*.jpg);;PGM (*.pgm)"), "", self,
"Read files", "Read files")<br>
<br>
</div>Strange, but it works.<br></div><br>-- <br>Alex Borghgraef