from PyQt5.QtWidgets import QApplication, QMainWindow, QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
from PyQt5.QtCore import Qt

class EditableTree(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Editable Tree Example")
        self.setGeometry(100, 100, 400, 300)

        # Central widget and layout
        central_widget = QWidget()
        layout = QVBoxLayout(central_widget)
        self.setCentralWidget(central_widget)

        # Tree widget
        self.tree = QTreeWidget()
        self.tree.setHeaderLabels(["Name"])
        self.tree.setColumnCount(1)
        self.tree.setEditTriggers(self.tree.DoubleClicked | self.tree.SelectedClicked | self.tree.EditKeyPressed)

        # Add some items
        root = QTreeWidgetItem(self.tree, ["Root"])
        root.setFlags(root.flags() | Qt.ItemIsEditable)
        child1 = QTreeWidgetItem(root, ["Child 1"])
        child1.setFlags(child1.flags() | Qt.ItemIsEditable)
        child2 = QTreeWidgetItem(root, ["Child 2"])
        child2.setFlags(child2.flags() | Qt.ItemIsEditable)

        self.tree.expandAll()
        layout.addWidget(self.tree)

if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    window = EditableTree()
    window.show()
    sys.exit(app.exec_())