GithubHelp home page GithubHelp logo

bheinks / qanytree Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 0.0 16 KB

An anytree-based implementation of QTreeView and QAbstractItemModel for PyQt5 supporting dynamic reordering, importing from and exporting to dictionary, undo/redo and more

Python 100.00%

qanytree's Introduction

qanytree

qanytree is an anytree-based implementation of QTreeView and QAbstractItemModel for PyQt5 supporting dynamic reordering, importing from and exporting to dictionary, undo/redo and more.

Requirements

anytree~=2.8
PyQt5~=5.15

Usage

QAnyTreeView subclasses PyQt5.QtWidgets.QTreeView and QAnyTreeModel subclasses PyQt5.QtCore.QAbstractItemModel. Simply add a QAnyTree widget to your GUI and set its model to an instance to QAnyTreeModel.

Example

import sys

from PyQt5.QtWidgets import QMainWindow, QApplication
from qanytree import QAnyTreeModel, QAnyTreeView


class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        super().__init__(parent)

        data = {
            'data': ['Key', 'Value'],
            'children': [{
                'data': [1, 'A'],
            }, {
                'data': [2, 'B'],
                'children': [{
                    'data': [3, 'C']
                }]
            }]
        }

        model = QAnyTreeModel(data)
        view = QAnyTreeView()
        view.setModel(model)

        self.setCentralWidget(view)


app = QApplication(sys.argv)
mainWindow = MainWindow()
mainWindow.show()

sys.exit(app.exec())

qanytree's People

Contributors

bheinks avatar

Stargazers

 avatar Megachweng avatar dl avatar mancelee avatar wandth avatar JT Tirado avatar

Watchers

 avatar

qanytree's Issues

qanytree with anytree node construct

I was looking for something a bit nicer than tkinter treeview.

anytree is a great library, and this looks like it improves a lot on the looks of tk...

Q: can I pass an anytree node (tree) to display using qanytree, or must it be a specific type of dictionary construction (like your example)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.