def setOpen(self, o): if o: self.setIcon(0, folderOpenIcon) else: self.setIcon(0, folderClosedIcon) if o and not self.childCount(): s = self.fullName() thisDir = QDir(s) if not thisDir.isReadable(): self.readable = 0 return files = thisDir.entryInfoList() if files: for f in files: # f is a QFileInfo # f.fileName is '.' or '..' or 'bearings' or... fileName = str(f.fileName()) if fileName == '.' or fileName == '..': continue elif f.isSymLink(): d = QTreeWidgetItem(self, fileName) #, 'Symbolic Link') d.setIcon(0, fileIcon) elif f.isDir(): if fileName == 'CVS': #bruce 060319 skip CVS directories, so developers see same set of directories as end-users # (implements NFR I recently reported) # WARNING: this is only legitimate for some applications of this module. # For now that's ok (we only use it in MMKit). Later this feature should be turned on # by an optional argument to __init__, and generalized to a list of files to not show # or to a filter function. continue d = Directory(self, fileName) else: if f.isFile(): s = 'File' else: s = 'Special' if not fileName[-3:] in self.filterList: continue d = FileItem(self, f.absFilePath(), fileName) d.setIcon(0, fileIcon) qt4todo('QTreeWidgetItem.setOpen(self, o)')
def setOpen(self, o): if o: self.setIcon(0, folderOpenIcon) else: self.setIcon(0, folderClosedIcon) if o and not self.childCount(): s = self.fullName() thisDir = QDir(s) if not thisDir.isReadable(): self.readable = 0 return files = thisDir.entryInfoList() if files: for f in files: # f is a QFileInfo # f.fileName is '.' or '..' or 'bearings' or... fileName = str(f.fileName()) if fileName == '.' or fileName == '..': continue elif f.isSymLink(): d = QTreeWidgetItem(self, fileName)#, 'Symbolic Link') d.setIcon(0, fileIcon) elif f.isDir(): if fileName == 'CVS': #bruce 060319 skip CVS directories, so developers see same set of directories as end-users # (implements NFR I recently reported) # WARNING: this is only legitimate for some applications of this module. # For now that's ok (we only use it in MMKit). Later this feature should be turned on # by an optional argument to __init__, and generalized to a list of files to not show # or to a filter function. continue d = Directory(self, fileName) else: if f.isFile(): s = 'File' else: s = 'Special' if not fileName[-3:] in self.filterList: continue d = FileItem(self, f.absFilePath(), fileName) d.setIcon(0, fileIcon) qt4todo('QTreeWidgetItem.setOpen(self, o)')
tree.setWindowTitle(tree.tr("Dir View")) tree.resize(250, 480) tree.show() for i in range(1,4): tree.hideColumn(i) sys.exit(app.exec_()) if False and __name__ == '__main__': a = QApplication(sys.argv) if 1: mw = DirView() a.setMainWidget(mw) mw.setCaption('PyQt Example - Directory Browser') mw.resize(400, 400) #mw.setSelectionMode(QTreeWidget.Extended) root = Directory(mw)#, '/huaicai') root.setOpen(1) mw.show() a.exec_() else: roots = QDir("/download") fiList = roots.entryInfoList() for drv in fiList: print "The file path is: ", str(drv.absFilePath()) a.exec_() # end
tree.setWindowTitle(tree.tr("Dir View")) tree.resize(250, 480) tree.show() for i in range(1, 4): tree.hideColumn(i) sys.exit(app.exec_()) if False and __name__ == '__main__': a = QApplication(sys.argv) if 1: mw = DirView() a.setMainWidget(mw) mw.setCaption('PyQt Example - Directory Browser') mw.resize(400, 400) #mw.setSelectionMode(QTreeWidget.Extended) root = Directory(mw) #, '/huaicai') root.setOpen(1) mw.show() a.exec_() else: roots = QDir("/download") fiList = roots.entryInfoList() for drv in fiList: print "The file path is: ", str(drv.absFilePath()) a.exec_() # end