Feature request #3408
Enhancement - Patch to add extra edit area and syntax highlighting to python console
|Pull Request or Patch supplied:||No||Resolution:|
|Easy fix?:||No||Copied to github as #:||13468|
This patch adds a second non-interactive python coding area to the python console. This lets the users write and rearrange python code before running it in the interactive console. Code from the edit area can be run in the interactive area using ctrl+return.
Syntax highlighting has also been implemented, for both the interactive console and the new edit area.
I also run reindent.py which is why the patch has more then what was just added by me.
#1 Updated by Martin Dobias over 9 years ago
- I don't really like the vertical split between the console text edit box and "source" text edit box - it takes away a lot of space of console. So now I see just very few lines of the console. I would suggest to rework this for better usability. For example, there could be a small tool button which would show/hide the additional edit box - that one would be hidden by default. Also I would suggest to make the split horizontal rather than vertical (the lines are typically not that long). Or even instead of a split it could open a new window for source editing (optionally with the possibility to load/save the code).
- the syntax highlighter tries to handle everything as python code. This is a bit unfortunate in the console since the output isn't typically python code. As you've noted, that's also why error messages are not highlighted correctly. If you'd like to dig a bit more into syntax highlighting, there's a nice python module "tokenize" which is able to split the text to python tokens: that could be used for parsing python instead of using those nasty regexps.
It would be good to address the issues mentioned above in order to get this into trunk.
Btw. maybe you are aware of Mark Summerfield's nice example of an interactive python console with GUI. It can also do completion and shows tooltips with help on method arguments. It can serve as a source of inspiration for further improvements of the python console in qgis:
#2 Updated by Nathan Woodrow over 9 years ago
No worries. I agree with both points, and both were a concern of mine when I first wrote it. Now that other people are thinking the same I will see how I can improve the usability.
I didn't know about Mark Summerfield's example. That will help a lot.