texstudio-org / texstudio

TeXstudio is a fully featured LaTeX editor. Our goal is to make writing LaTeX documents as easy and comfortable as possible.
http://www.texstudio.org/
GNU General Public License v3.0
2.76k stars 343 forks source link

Feature Request: Python integration #924

Open OgreTransporter opened 4 years ago

OgreTransporter commented 4 years ago

Just a thought of mine! How about integrating Python? A Python console as a window (see issue #864) would be easier to implement than wrappers for the many different terminal/shell programs (cmd, ps, bash, sh, zsh, ...) on the different systems. The result of a script is also the same on all systems. Qt Script has also been marked as deprecated for quite some time and will probably disappear at some point. Python could replace this. Qt should also get more and more Python integration in the future.

MeanSquaredError commented 4 years ago

Already discussed here: https://github.com/texstudio-org/texstudio/issues/815#issuecomment-559609365 TLDR: Once QtScript is dropped completely, it will be replaced by QJsEngine. Python support in TXS has its merits, but compatibility with existing scripts takes priority.

IMHO Python support is nice to have, but it would be best to have it as an additional option besides QtScript/QJsEngine. This means implementing some kind of infrastructure that supports different scripting languages as TXS plugins (and QJsEngine would be just another pluggable language). This way adding Python support would be less intrusive for the current codebase.

sunderme commented 4 years ago

scripting is used way too little to merit all the hassle with setting python up (over all supported platforms) So , it is rather unlikely to happen (especially as there is no real benefit in using python instead of javascript in the context of txs scripting)

OgreTransporter commented 4 years ago

Python support in TXS has its merits, but compatibility with existing scripts takes priority.

When switching from QtScript to JavaScript, the existing scripts are not compatible either.

Python has the additional advantage that you can include a lot of external data and services. When writing a publication I could read the results directly from my calculations and automatically integrate them into the text and update them if necessary. Machine Learning (e.g. TensorFlow) can also be used in scripts.

scripting is used way too little to merit all the hassle with setting python up (over all supported platforms)

The API is the same on all systems. You can also start with a Python option. Poppler can also be switched off.

MeanSquaredError commented 4 years ago

QtScript uses WebKit's JavaScript implementation which is compatible with ECMAScript-262. QJsEngine uses Qt's own implementation of ECMAScript7-compatible implementation. So for a script writer it should not make a difference and all scripts written for QtScript should run fine on QJsEngine.

I am not arguing against the merits of Python, but as far as I can see TXS currently does not have the infrastructure to support multiple scripting languages. In order to add support for Python do that it would need the following:

  1. Infrastructure for pluggable scripting languages.
  2. QtScript/QJsEngine C++ code in TXS converted to use the new infrastructure from 1.
  3. Python scripting plugin that integrates with the infrastructure from 1.
  4. Changes to the TXS UI to add the settings for Python scripting.
  5. Tests to make sure that the old QtScript/QJSEngine functionality works as before.

I think that if someone provides these things they will be added to TXS.