我一直在努力使用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()
任何帮助将不胜感激。谢谢!