def open_image_fd(self, dialog_text="Open Image", default_folder=""):
"""Opens a file dialog, allowing user to select an image file.
Creates a QImage object from the filename selected by the user in the
popup file dialog menu.
Args:
dialog_text [Optional(str.)]: Text to prompt user with in open file
dialog. Defaults to "Open Image".
default_folder [Optional(str.)]: Path of the default directory to open
the file dialog box to. Defaults to "".
Returns:
QImage: Image object created from selected image file.
None: Returns None if no file was selected in the dialog box.
"""
fname = QtWidgets.QFileDialog.getOpenFileName(self, dialog_text, default_folder) # TODO: Filter to show only image files
if fname:
image = QtGui.QImage(fname[0])
else:
image = None
return image
评论列表
文章目录