Esempio n. 1
0
    def __init__(self, root, parent=None):
        super(MFileTree, self).__init__(parent)
        self.setStyleSheet("color:rgb(189, 195, 199);")
        # model = QFileSystemModel()
        # model.setRootPath(QDir.rootPath())
        # view = QTreeView(parent)
        # self.show()
        #app = QApplication(sys.argv)
        # Splitter to show 2 views in same widget easily.
        splitter = QSplitter()
        # The model.
        model = QFileSystemModel()
        # You can setRootPath to any path.
        model.setRootPath(root)
        # List of views.
        self.views = []
        #self.view = QTreeView(self)
        # self.itemPressed.connect(self.itemClicked)
        self.setModel(model)
        self.setRootIndex(model.index(root))
        self.header().setStyleSheet("background:rgb(70, 80, 88);")
        # for ViewType in (QColumnView, QTreeView):
        # # Create the view in the splitter.
        # view = ViewType(splitter)
        # # Set the model of the view.
        # view.setModel(model)
        # # Set the root index of the view as the user's home directory.
        # view.setRootIndex(model.index(QDir.homePath()))
        # # Show the splitter.
        # splitter.show()
        self.layout = QtGui.QHBoxLayout()
        # self.layout.addWidget(self)

        self.setLayout(self.layout)

        # Maximize the splitter.
        splitter.setWindowState(Qt.WindowMaximized)
Esempio n. 2
0
import sys

from PyQt4.QtGui import (QApplication, QColumnView, QFileSystemModel,
                         QSplitter, QTreeView)
from PyQt4.QtCore import QDir, Qt

if __name__ == '__main__':
    app = QApplication(sys.argv)
    # Splitter to show 2 views in same widget easily.
    splitter = QSplitter()
    # The model.
    model = QFileSystemModel()
    # You can setRootPath to any path.
    model.setRootPath(QDir.rootPath())
    # List of views.
    views = []
    for ViewType in (QColumnView, QTreeView):
        # Create the view in the splitter.
        view = ViewType(splitter)
        # Set the model of the view.
        view.setModel(model)
        # Set the root index of the view as the user's home directory.
        view.setRootIndex(model.index(QDir.homePath()))
    # Show the splitter.
    splitter.show()
    # Maximize the splitter.
    splitter.setWindowState(Qt.WindowMaximized)
    # Start the main loop.
    sys.exit(app.exec_())
Esempio n. 3
0
http://doc.qt.nokia.com/latest/model-view-programming.html.
"""
import sys

from PyQt4.QtGui import (QApplication, QColumnView, QFileSystemModel,
                         QSplitter, QTreeView)
from PyQt4.QtCore import QDir, Qt

if __name__ == '__main__':
    app = QApplication(sys.argv)
    # Splitter to show 2 views in same widget easily.
    splitter = QSplitter()
    # The model.
    model = QFileSystemModel()
    # You can setRootPath to any path.
    model.setRootPath(QDir.rootPath())
    # List of views.
    views = []
    for ViewType in (QColumnView, QTreeView):
        # Create the view in the splitter.
        view = ViewType(splitter)
        # Set the model of the view.
        view.setModel(model)
        # Set the root index of the view as the user's home directory.
        view.setRootIndex(model.index(QDir.homePath()))
    # Show the splitter.
    splitter.show()
    # Maximize the splitter.
    splitter.setWindowState(Qt.WindowMaximized)
    # Start the main loop.
    sys.exit(app.exec_())