From eea4d307ecbd8500bc429be7b0c05cf4097a5686 Mon Sep 17 00:00:00 2001 From: Alain Romedenne Date: Thu, 13 Dec 2018 15:06:45 -0200 Subject: More pages on Python scripts Change-Id: I5d8db28da384f52ee835195d3eb889fde0fe33b3 Signed-off-by: Olivier Hallot Reviewed-on: https://gerrit.libreoffice.org/65117 Tested-by: Jenkins --- source/text/sbasic/python/python_shell.xhp | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 source/text/sbasic/python/python_shell.xhp (limited to 'source/text/sbasic/python/python_shell.xhp') diff --git a/source/text/sbasic/python/python_shell.xhp b/source/text/sbasic/python/python_shell.xhp new file mode 100644 index 0000000000..38e4a72c12 --- /dev/null +++ b/source/text/sbasic/python/python_shell.xhp @@ -0,0 +1,59 @@ + + + + + + Python Interactive Shell + /text/sbasic/python/python_shell.xhp + + + + + Python console + Python Interactive Shell + +
+ Running Python Interactive Console +
+ The Python interactive console, also known as Python interpreter or Python shell, provide programmers with a quick way to execute commands and try out and test code without creating a file. %PRODUCTNAME Python modules documentation can obtained from the terminal. + + Using a Basic macro: + + Sub interpreter_console + ps = CreateUnoService("com.sun.star.util.PathSettings") + install_path = ConvertFromURL(ps.Module) + Shell( install_path + GetPathSeparator() + "python" ) + End Sub + + Using a Python macro: + + # -*- coding: utf-8 -*- + from __future__ import unicode_literals + + import uno, os, subprocess + + def interpreter_console(): + ctx = XSCRIPTCONTEXT.getComponentContext() + smgr = ctx.getServiceManager() + ps = smgr.createInstanceWithContext("com.sun.star.util.PathSettings", ctx) + install_path = uno.fileUrlToSystemPath(ps.Module) + pgm = install_path + os.sep + "python" # Python shell/console path + subprocess.Popen(pgm) # Start Python interactive Shell + + + Usage: + + Python Interactive Console + +
+ +
+ +
-- cgit