Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved QPlainTextEdit as a Python editor?

    General and Desktop
    3
    7
    147
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      lansing last edited by lansing

      I'm don't really know what I should be looking for so I some help. I have a QPlainTextEdit that I want it to act as a Python editor. The main usage for it is to catch errors, warnings and print command when I run the script. I would also like it to be aware of the variable's type in the script so to provide the corresponded attributes and methods as autocompleter.

      For example, when I define a as a string, entering . after will trigger the autocompleter for all of its methods.

      a = "hello"
      a.lower()
      

      Where do I need to look?

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        You can check the QSyntaxHighlighter example but this will require a QTextEdit.

        However, from the looks of your description, you seem to want to have support for a language server.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        L 1 Reply Last reply Reply Quote 1
        • L
          lansing @SGaist last edited by

          @SGaist
          Thanks, I checked out the Python language server by Microsoft, looks like it's the right path. But what about catching errors and warnings? What do I use?

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Take a look at Jedi

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 1
            • gde23
              gde23 last edited by

              Also maybe its worth taking a look at QScintilla which has build in functionality for auto-completion, highlighting and those things.
              Here a link to some overview and here to the download

              1 Reply Last reply Reply Quote 2
              • L
                lansing last edited by

                After testing out some Python codes in Visual Studio Code (it has Python language server implemented), I don't really like what I see. Some methods from my imported modules has a return type(class) and the autocompleter was not able to feed me the attributes and methods under that type. For example, the method myModule.getNewClass() will return a variable with type NewClass. And NewClass has a method called getName(),

                output = myModule.getNewClass()
                

                But then when I went like output., the autocompleter, instead of giving me getName() as the choice, it fed me all the methods from all the import modules.

                So this route is a no go for me.

                1 Reply Last reply Reply Quote 0
                • gde23
                  gde23 last edited by

                  If the auto-completer is not working the reason might be, that its the wrong format. There are different ways to define doc strings and how they are stored, e.g. in VIM it uses Jedi but cannot see the docstrings in c-extensions, however you can make them available via stub files e.g. in pybind11 and so on...
                  TLDR: its a bit complicated and not only depends on your autocompleter but also on how you add the docstrings to your python module.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post