ファイル選択ダイアログ

2014/12/28

Python2.7.6, pyQt4.11

#-*- coding:utf-8 -*-

import sys
from PyQt4 import QtCore, QtGui

def main():
    app = QtGui.QApplication(sys.argv)

    w = QtGui.QWidget()
    btn = QtGui.QPushButton(u"ファイルダイアログを開く",w)
    btn.clicked.connect(showFileDialog)

    w.show()
    sys.exit(app.exec_())

def showFileDialog():
    fd = QtGui.QFileDialog()
    fp = fd.getOpenFileName()
    print(fp)

if __name__ == "__main__":
    main()


Dialogs in PyQt4
http://zetcode.com/gui/pyqt4/dialogs/

QFileDialog Class Reference
http://pyqt.sourceforge.net/Docs/PyQt4/qfiledialog.html