Skip to content

yjg30737/pyqt-editable-treewidget-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyqt-editable-treewidget-example

PyQt example of QTreeWidget which is editable

Intuitive enough to use, but this is for example only

Requirements

  • PyQt5 >= 5.8

Setup

  • git clone ~

Feature

  • Show the exmaple of adding & deleting the tree widget item in convinient way
  • Support multiple options:
    • make it unable to edit the parent item's name which has the child
    • user can make the certain item not editable
  • Convert QTreeWidget hierarchy into JSON format
    • convert the QTreeWidget hierarchy into JSON format (in Python, array of Python dictionary) to save in "tree.json"
    • Load the saved JSON content from "tree.json" and convert it into QTreeWidget when user executes the window again

The each object of tree.json contains multiple properties - name of the item(name), editable flag(editable), childs of the item(data)

Usage

Key command

  • Enter/Return - Add new child
  • F2 - Rename attribute
  • Delete - Remove attribute
  • Up/Down - Previous/next attribute
  • Shift+Up/Down - Go parent/child attribute

Context Menu

  • Add parent attribute
  • Add child attribute
  • Rename - rename the item
  • Editable - check to make the item editable or not

Example

Code Sample

from PyQt5.QtWidgets import QApplication
from pyqt_editable_treewidget_example import MainWindow

if __name__ == "__main__":
    import sys

    app = QApplication(sys.argv)
    example = MainWindow()
    example.show()
    app.exec_()

Result

Basic control of the treewidget

pyqt_editable_treewidget_example.mp4

Whole window (v0.0.161)

image

About

PyQt example of QTreeWidget which is editable (intuitive enough to use)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages