QFileDialogメモ

2020/11/06 categories:PyQt5| tags:PyQt5|Python|

QFileDialog.getOpenFileName

import sys
from PyQt5 import QtWidgets

app = QtWidgets.QApplication(sys.argv)
return_value = QtWidgets.QFileDialog.getOpenFileName(None, 'Open file', 'D:/', 'Image file(*.jpg *.png)')
print(return_value)
('D:/Python/test/test.png', 'Image file(*.jpg *.png)')
('', '')

QFileDialog.getOpenFileNames

import sys
from PyQt5 import QtWidgets

app = QtWidgets.QApplication(sys.argv)
return_value = QtWidgets.QFileDialog.getOpenFileNames(None, 'Open files', 'D:/', 'Image file(*.jpg *.png)')
print(return_value)
(['D:/Python/test/test.jpg', 'D:/Python/test/test.png'], 'Image file(*.jpg *.png)')
([], '')

QFileDialog.getExistingDirectory

import sys
from PyQt5 import QtWidgets

app = QtWidgets.QApplication(sys.argv)
return_value = QtWidgets.QFileDialog.getExistingDirectory(None, 'Open folder', 'D:/')
print(return_value)
D:/Python/test/test_directory
 

空の文字列(="")が返ります

QFileDialog.getSaveFileName

import sys
from PyQt5 import QtWidgets

app = QtWidgets.QApplication(sys.argv)
return_value = QtWidgets.QFileDialog.getSaveFileName(None, 'Save file', 'D:/', 'Image file(*.jpg *.png)')
print(return_value)
('D:/Python/test/test.jpg', 'Image file(*.jpg *.png)')
('', '')

Share post

Related Posts

コメント