[Python] Python interactive shell emulator

Keyboard macros or custom scripts

[Python] Python interactive shell emulator

Postby hubert lambert » Fri Oct 13, 2017 11:58 am

In order to further make the development of python macros easier, I propose below a small script that emulates, as close as possible, the python interactive shell:

pyconsole1.jpg

What one can do with such a tool:
- interact directly with a document and test "live" the methods of the uno api (maybe also useful for other languages, such basic)
- quickly verify python expressions in the context of the embedded interpreter
- display the output of a script running in parallel or started from the shell (all modules visible from the office program can be imported)
- debug a script using pdb's runcall function (will not work with scripts embedded in documents) :
Code: Select all   Expand viewCollapse view
import pythonSamples.TableSample
pdb.runcall(pythonSamples.TableSample.createTable)
pyconsole_pdb.jpg
- get quick info on any function using the builtin help() command
- explore living uno objects with introspection tools such as MRI or Xray (if installed)
- ...

To install the script, just unzip the file into the <user>/Scripts/python directory of your application.
A modal version of this tool should be available with the next release of APSO.

Regards.
Attachments
Console.py.zip
(5.6 KiB) Downloaded 23 times
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
hubert lambert
 
Posts: 59
Joined: Mon Jun 13, 2016 10:50 am

Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 4 guests