Giter Club home page Giter Club logo

pyqt-editable-treewidget-example's Introduction

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

pyqt-editable-treewidget-example's People

Contributors

yjg30737 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pyqt-editable-treewidget-example's Issues

Two Suggestions about this Project

Hi, there. Recently I've been working on the QTreeWidget in PyQt5. And your project give me some great inspirations which I would appreciate. Here are some ideas that came through:

  1. How to make it editable within more than one single column?
  2. How to allow users to partially edit the content of the widget? For instance, they cannot edit header labels and the label of the first parent attribute but can actually edit the rest parts. Can this goal be achieved by presetting parameters in the class EditableTreeWidget?
  3. Noticed that you've set the ContextMenuPolicy to Qt.ActionsContextMenu, how to save the change by users?
    Looking forwards to your early reply^^

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.