我一直在努力学习如何使用wxFileDialog从一个文件夹中加载多个图片,然后将这些图片添加到一个数组中。代码如下:
def loadImages(self, e):
wildcard = 'JPEG files (*.jpg)|*.jpg|' +\
'PNG files (*.png)|*.png|' +\
'Other files (*.*)|*.*'
dlg = wx.FileDialog(self, "Choose images",
wildcard=wildcard, style=wx.FD_OPEN | wx.FD_MULTIPLE)
if dlg.ShowModal() == wx.ID_OK:
self.imageName = dlg.GetFilename()
self.directory = dlg.GetDirectory()
self.image = self.directory + '/' + self.imageName
for dlg in dlg.GetPaths():
image = Image.open(dlg)
self.imagesA = np.append(self.imagesA, image)
dlg.Destroy()
任何帮助都将不胜感激。谢谢!你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐