import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
def __init__(self, parent=None):
super(Window, self).__init__(parent)
self.UI()
def UI(self):
self.setCentralWidget(self.central_widget)
self.statusBar().showMessage("Ready")
page1 = FirstWidget(self)
page1.visualize_btn.clicked.connect(self.P_2)
self.central_widget.addWidget(page1)
self.setGeometry(10, 10, 800, 500) #All three methods have been inherited from the QWidget class.
self.showMaximized()
self.setWindowTitle('PTV')
self.
setWindowIcon(QIcon('tuc_logo.png'))
def P_2(self):
page2 = VisualizeWidget(self)
self.central_widget.addWidget(page2)
self.central_widget.setCurrentWidget(page2)
def __init__(self, parent=None):
super(FirstWidget, self).__init__(parent)
self.buttons()
def buttons(self):
self.buttonsLayout.addWidget(self.btn2)
self.visualize_btn = self.btn2
self.setLayout(self.buttonsLayout)
def __init__(self, parent=None):
super(VisualizeWidget, self).__init__(parent)
#Creation of the left layout
self.dirmodel = QFileSystemModel()
self.
dirmodel.
setFilter(QDir.
NoDotAndDotDot |
QDir.
AllDirs) # Don't show files, just folders
self.folder_view.setModel(self.dirmodel)
self.
folder_view.
clicked[QModelIndex].
connect(self.
clicked)
self.selectionModel = self.folder_view.selectionModel()
self.now_layout.addWidget(self.folder_view)
self.left_widget.setLayout(self.now_layout)
#Creation of the right layout
#self.right_widget = QTextEdit();
self.right_layout.addWidget(self.btn1)
self.right_widget.setLayout(self.right_layout)
splitter_filebrowser
= QSplitter(Qt.
Horizontal) splitter_filebrowser.addWidget(self.left_widget)
splitter_filebrowser.addWidget(self.right_widget)
splitter_filebrowser.setStretchFactor(1, 1)
hbox.addWidget(splitter_filebrowser)
self.setLayout(hbox)
def set_path(self):
self.dirmodel.setRootPath("")
def clicked(self, index):
index = self.selectionModel.currentIndex()
dir_path = self.dirmodel.filePath(index)
self.filemodel.setRootPath(dir_path)
self.file_view.setRootIndex(self.filemodel.index(dir_path))
def main():
win = Window()
win.show()
app.exec_()
if __name__ == '__main__':
sys.exit(main())
Bookmarks