标签:
def findImage(self,ext=‘jpg|png|bmp|gif‘):
import os
image=self.OpenEdit.text()
allfiles = []
needExtFilter = (ext != None)
for root,dirs,files in os.walk(unicode(image)):
for filespath in files:
filepath = os.path.join(root, filespath)
extension = os.path.splitext(filepath)[1][1:]
if needExtFilter and extension in ext:
allfiles.append(filepath)
elif not needExtFilter:
allfiles.append(filepath)
model=QStandardItemModel(self)
for pngitem in allfiles:
path=os.path.basename(unicode(pngitem)).split(‘.‘)[0]
path=QStandardItem(QIcon(unicode(pngitem)),unicode(path))
for i in range(len(allfiles)):
item=QStandardItem(path)
item.setCheckState(Qt.Unchecked)
item.setCheckable(True)
model.appendRow(item)
self.listImage.setModel(model)
self.listImage.setIconSize(QSize(70,70))
self.listImage.setResizeMode(QListView.Adjust)
self.listImage.setViewMode(QListView.IconMode)
self.listImage.setMovement(QListView.Static)
self.listImage.setSpacing(45)
self.listImage.setWrapping(True)
return allfiles
标签:
原文地址:http://www.cnblogs.com/mhxy13867806343/p/4299993.html