Start New Discussion within our Software Development Community

A simple test of PySide's QFileDialog widget and its method getOpenFileNames. Use method getOpenFileName if you want just one file name.

''' ps_test_QFileDialog2.py
a very simple template to test PySide widgets ...

get a list of full path multiple filenames via
QFileDialog.getOpenFileNames()
(press ctrl key or shift key when selecting multiple files)

for Python33 you can use the Windows self-extracting installer
PySide-1.1.2qt483.win32-py3.3.exe
from:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
also:
http://qt-project.org/wiki/PySide_Binaries_Windows
PySide is the official LGPL-licensed version of PyQT

Tested with Python27 and Python33  by   vegaseat  16apr2013
'''

from PySide.QtCore import *
from PySide.QtGui import *

# replace [] with sys.argv for commandline
app = QApplication([])

# ----- start your widget test code ----

caption = 'Open file'
# use current/working directory
directory = './'
filter_mask = "Python/Text files (*.py *.pyw *.txt)"
filenames = QFileDialog.getOpenFileNames(None,
    caption, directory, filter_mask)[0]

print(filenames)  # test

# ---- end of widget test code -----

# for this case ...
app.processEvents()
#app.exec_()
The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.