[Python] Python interactive shell emulator

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
hubert lambert
Posts: 145
Joined: Mon Jun 13, 2016 10:50 am

[Python] Python interactive shell emulator

Post by hubert lambert »

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

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 227 times
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
Post Reply