Python Forum

Full Version: How to create dictionary based editor
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello All,

I would like to edit the QPlainTextEdit() widgets with dictionary format. For example like below.
data:
  rootdict:
    subdict:
      mydict1:
        mykey1: 1
      mydict2:
        mykey2: 2
mydict3:
  mykey3: 3
I wanted to include the mydict3 dictionary within the subdict dictionary in the Editor. However, when I place the cursor at the end of the mykey2 key, then I enter immediately jumps to the first character position of the following line. Instead, I would prefer the cursor to remain at the starting position of mykey2 on the next line. This would allow me to press backspace to return to the position where mydict2 begins. Unfortunately, this isn't happening as I had hoped. Additionally, even after pressing space, attempting to execute this dictionary results in an error.

Do you have any suggestions on automatically making this editor work with a dictionary or JSON format?
I don't think a text editor is a good idea. Dictionaries and json are hierarchical, so it makes sense to base your editor on something that understands hierarchy. Here's a json editor that uses a QTreeWidget.

https://github.com/rBrenick/json-editor

If you want to make a text editor that works somewhat with editing dictionaries or json, look for a project that uses qt to write a code editor. Like this one. Unfortunately it is written in C++.

https://github.com/Megaxela/QCodeEditor

Here's one written in python using PyQt,.

https://riverbankcomputing.com/software/...illa/intro
Hello All,
I wanted to create a json based editor.
data:
  rootdict:
    subdict:
      mydict1:
        mykey1: 1
      mydict2:
        mykey2: 2
Here in the above json data I wanted to add the below json dictionary to this pyqt editor.
mydict3:
  mykey3: 3
how to create a json based editor instead of plain editor.

any idea would be appreciated.
Thanks,
maiya