def createLeftSide(self):
        self.leftSideGB = QGroupBox()

        home_directory = "./app/"

        palette = QPalette()
        palette.setColor(QPalette.Window, QColor(30, 30, 30))

        model = QDirModel()
        view = QTreeView()
        view.setStyleSheet("QTreeView { border: 0px; }")
        view.setModel(model)
        view.setRootIndex(model.index(home_directory))
        view.setColumnHidden(1, True)
        view.setColumnHidden(2, True)
        view.setColumnHidden(3, True)
        view.show()
        view.setPalette(palette)

        runButton = QPushButton("►")
        stopButton = QPushButton("❚❚")

        bottomBar = QHBoxLayout()
        bottomBar.addWidget(runButton)
        bottomBar.addWidget(stopButton)

        layout = QVBoxLayout()
        layout.addWidget(view)
        layout.addLayout(bottomBar)
        layout.setStretch(0, 2)
        self.leftSideGB.setLayout(layout)
    def display(self, model):
        app = QApplication.instance()

        # Create QApplication if it does not exist
        if not app:
            app = QApplication(sys.argv)

        tree = QTreeView()
        tree.setModel(model)
        tree.show()
        app.exec_()
        return tree
Beispiel #3
0
## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
##
## $QT_END_LICENSE$
##
#############################################################################
"""PySide2 port of the remoteobjects/modelviewclient example from Qt v5.x"""

import sys

from PySide2.QtCore import QUrl
from PySide2.QtWidgets import (QApplication, QTreeView)
from PySide2.QtRemoteObjects import QRemoteObjectNode

if __name__ == '__main__':
    app = QApplication(sys.argv)
    node = QRemoteObjectNode(QUrl("local:registry"))
    node.setHeartbeatInterval(1000)
    view = QTreeView()
    view.setWindowTitle("RemoteView")
    view.resize(640, 480)
    model = node.acquireModel("RemoteModel")
    view.setModel(model)
    view.show()

    sys.exit(app.exec_())
Beispiel #4
0
            return self.createIndex(row, column, childItem)
        else:
            return QModelIndex()

    def parent(self, index):
        if not index.isValid():
            return QModelIndex()

        childItem = index.internalPointer()
        if not childItem:
            return QModelIndex()

        parentItem = childItem.parent()

        if parentItem == self.rootItem:
            return QModelIndex()

        return self.createIndex(parentItem.row(), 0, parentItem)


if __name__ == "__main__":
    # http://blog.mathieu-leplatre.info/filesystem-watch-with-pyqt4.html
    import sys

    # app = QApplication(sys.argv)
    TreeView = QTreeView()
    TreeModel = NodeTree(
        TreeView, [['A', ['a', 1], ['b', ['c', 1]]], ['C', 'D'], ['E', 'F']])
    TreeView.setModel(TreeModel)
    TreeView.show()
    # app.exec_()