-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathFileSystem_view.py
More file actions
40 lines (30 loc) · 1.03 KB
/
FileSystem_view.py
File metadata and controls
40 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sys
import os
from PyQt5.QtWidgets import QApplication, QWidget, QTreeView, QFileSystemModel, QVBoxLayout
from PyQt5.QtCore import QModelIndex
class FileSystemView(QWidget):
def __init__(self, dir_path):
super().__init__()
#TITULO Y DIMENSIONES DE LA VENTANA.
self.setWindowTitle('File System Viewer')
self.setGeometry(300, 300, 800, 300)
#DEFINIR DIRECTORIO.
self.model = QFileSystemModel()
self.model.setRootPath(dir_path)
#GENERAR VISTA DE ARCHIVOS Y CARPETAS.
self.tree = QTreeView()
self.tree.setModel(self.model)
self.tree.setRootIndex(self.model.index(dirPath))
self.tree.setColumnWidth(200,250)
self.tree.setAlternatingRowColors(True)
#MOSTRAR VENTANA CON LAS VISTA.
layout = QVBoxLayout()
layout.addWidget(self.tree)
self.setLayout(layout)
if __name__ == '__main__':
app = QApplication(sys.argv)
#DIRECTORIO BASE.
dirPath = os.getcwd()
demo = FileSystemView(dirPath)
demo.show()
sys.exit(app.exec_())