Python Forum
[PyQt] How to create dictionary based editor
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] How to create dictionary based editor
#1
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?
Reply
#2
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
Reply
#3
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
buran write Dec-02-2024, 08:01 AM:
Please, don't create new threads unnecessarily. New thread merged in the original one.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Libraries/Tools to create an editor similar to Tiled MrTim 13 7,081 May-12-2021, 02:45 PM
Last Post: deanhystad
  PyQt5: Add Variable Number of Rows to Layout Based on Python Dictionary kennybassett 2 5,867 Oct-02-2018, 02:05 PM
Last Post: Alfalfa

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020