Here is a Python script for Krita that will help you read the Python functions of a document.
Open a new document, create a python script, and add the source code. Use the main menu Tools - Scripts - Ten Scripts to choose the place where the script exists and the combination of keys for execution.
This is the source code:
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QTreeWidget, QTreeWidgetItem, QTextEdit
from krita import *
class LayerContentDialog(QWidget):
def __init__(self, content):
super().__init__()
self.setWindowTitle("Conținutul preluat cu dir():")
self.setGeometry(100, 100, 800, 600)
main_layout = QVBoxLayout()
tree_widget = QTreeWidget()
tree_widget.setHeaderLabels(["Nume", "Tip"])
self.add_items_recursive(tree_widget, content)
main_layout.addWidget(tree_widget)
close_button = QPushButton("Închide")
close_button.clicked.connect(self.close)
main_layout.addWidget(close_button)
self.setLayout(main_layout)
def add_items_recursive(self, tree_widget, items, parent_item=None):
for item in items:
if isinstance(item, str):
if parent_item:
item_widget = QTreeWidgetItem(parent_item, [item, type(getattr(doc, item)).__name__])
help_text = "\n".join(dir(getattr(doc, item)))
item_widget.addChild(QTreeWidgetItem([help_text]))
else:
item_widget = QTreeWidgetItem(tree_widget, [item, type(getattr(doc, item)).__name__])
help_text = "\n".join(dir(getattr(doc, item)))
item_widget.addChild(QTreeWidgetItem([help_text]))
elif isinstance(item, type):
parent = QTreeWidgetItem(tree_widget, [item.__name__, "Modul"])
self.add_items_recursive(tree_widget, dir(item), parent)
doc = Krita.instance().activeDocument()
layerContents = dir(doc)
dialog = LayerContentDialog(layerContents)
dialog.show()
The result for this script is this:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPMLn6YIOcF8HIUMe2P3iHjs3sRz3aIOPVx19yxAf3U46Tw1lQ4kUs5TtFq0rir2VT7nJOnxHeCnlvfWyjuUuE21OF-OxDOW6mRpvPEp4UifiK7L9189PkoPCBYa3VC5s6qa2QI7jY-ZyDQnC6zhxuUJCmIsO_CtBInI-P6HvfrzCwQ54vIBDuKR0v9ow/s1600/krita_dir_001.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZJybAg6pr8bueaPcghh6VS-TRxX6dKalKs_fACOiQo28arOLE31TJoF6v-6080rwMpxve2x94Ntr8NFRg9u9rk56ybUpKMXpTz_eG2v0-s2IcbiJQxTPYMHS3HHV-rHpnDkR719AcfzS9u4F-1fzYUOQjp2i8neq4FFquAk_3WeGAp2KpQg7nHGoC-Y8/s1600/krita_dir_002.png)
You can use the main menu Tools - Scripts - Scripter to write, test, save, and run the source code.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPIzJ9G0XFMVLrWAGv8ewPWsqcG2QufuMF9nbmH2fi-_Psj23OMhMEP7oj1GAiYxmRbQUZ6j8II1bQhWlysyG91CGbTfOkjTvOa7IC6Ip7OYElUIvU_-cSGPSUs3x5RcR-hFMY2qb9jYhAA64rYLKqVBdqUZTNqPSJuKRkAkPZOP6nvcMVwN-8FMJDPmI/s1600/krita_dir_003.png)