I'm trying to make a File Browser with Qt Designer and PyQt5 but it dosen't work well, I think it mitght be the self.ui
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton, QFileDialog, QTreeWidget, QTreeView, QTreeWidgetItem, QSplitter, QFileSystemModel, QColumnView
from PyQt5.QtCore import pyqtSlot, QFile, QTextStream, QDir
from PyQt5 import QtCore
from PyQt5 import QtWidgets
from PyQt5.QtGui import QIcon
import os
from Oracle3_ui import Ui_MainWindow
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.current_path = None
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.Files_View()
###########
## TreeView
def Files_View(self):
thethis = self.ui.TreeGlosario
directory = "C:\Users\jonat\OneDrive\JONY\DOCUMENTOS\Oraculo\Files\Elarchivador\Glosario"
path = directory
self.model = QtWidgets.QFileSystemModel()
self.model.setRootPath((QtCore.QDir.rootPath()))
thethis.setModel(self.model)
thethis.setRootIndex(self.model.index(path))
thethis.setSortingEnebled(True)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec())
TreeGlosario is the TreeWidget that i have in the ui file
i tried various ways but i can't do it, i'm new in qt designer, but i expected that it will work, but then give me this think:
File "c:\Users\jonat\OneDrive\JONY\DOCUMENTOS\Oraculo\Main.py", line 59 directory = "C:\Users\jonat\OneDrive\JONY\DOCUMENTOS\Oraculo\Files\Elarchivador\Glosario" ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Pls Help me with the code