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 --- AllLangHelp_sbasic.mk | 3 +- Package_html_media.mk | 1 + source/media/helpimg/python/python_shell.png | Bin 0 -> 34644 bytes source/text/sbasic/python/main0000.xhp | 9 ++-- source/text/sbasic/python/python_ide.xhp | 13 ++++-- source/text/sbasic/python/python_locations.xhp | 15 ++++--- source/text/sbasic/python/python_shell.xhp | 59 +++++++++++++++++++++++++ 7 files changed, 86 insertions(+), 14 deletions(-) create mode 100644 source/media/helpimg/python/python_shell.png create mode 100644 source/text/sbasic/python/python_shell.xhp diff --git a/AllLangHelp_sbasic.mk b/AllLangHelp_sbasic.mk index ec22b518ee..303228599f 100644 --- a/AllLangHelp_sbasic.mk +++ b/AllLangHelp_sbasic.mk @@ -364,8 +364,7 @@ $(eval $(call gb_AllLangHelp_add_helpfiles,sbasic,\ helpcontent2/source/text/sbasic/python/main0000 \ helpcontent2/source/text/sbasic/python/python_ide \ helpcontent2/source/text/sbasic/python/python_locations \ - helpcontent2/source/text/sbasic/shared/stardesktop \ - helpcontent2/source/text/sbasic/shared/uno_objects \ + helpcontent2/source/text/sbasic/python/python_shell \ )) # vim: set noet sw=4 ts=4: diff --git a/Package_html_media.mk b/Package_html_media.mk index 798d9be1ac..1c31f353ef 100644 --- a/Package_html_media.mk +++ b/Package_html_media.mk @@ -284,6 +284,7 @@ $(eval $(call gb_Package_add_files_with_dir,helpcontent2_html_media,$(LIBO_SHARE helpimg/starmath/un21214.png \ helpimg/starmath/un21215.png \ helpimg/starmath/un21221.png \ + helpimg/python/python_shell.png \ helpimg/sw_paste_range.png \ helpimg/sw_signatureline01.png \ helpimg/sw_signatureline02.png \ diff --git a/source/media/helpimg/python/python_shell.png b/source/media/helpimg/python/python_shell.png new file mode 100644 index 0000000000..afb1738a0f Binary files /dev/null and b/source/media/helpimg/python/python_shell.png differ diff --git a/source/text/sbasic/python/main0000.xhp b/source/text/sbasic/python/main0000.xhp index 989ea22d0e..f83d1b72c6 100644 --- a/source/text/sbasic/python/main0000.xhp +++ b/source/text/sbasic/python/main0000.xhp @@ -8,7 +8,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. * --> - Python Scripts @@ -19,17 +18,21 @@ macros;Python scripts Python;macros + APSO + Alternative Python Scripts Organizer - %PRODUCTNAME Python Scripts Help +

%PRODUCTNAME Python Scripts Help

%PRODUCTNAME provides an Application Programming Interface (API) that allows controlling the $[officename] components with different programming languages by using the $[officename] Software Development Kit (SDK). For more information about the $[officename] API and the Software Development Kit, visit https://api.libreoffice.org This help section explains the most common Python script functions for %PRODUCTNAME. For more in-depth information please refer to the Designing & Developing Python Applications on the Wiki.
- Working with Python Scripts in %PRODUCTNAME. +

Working with Python Scripts in %PRODUCTNAME.

+ You can execute Python scripts choosing Tools - Macros – Run macro.... Editing scripts can be done with your preferred text editor. Python scripts are present in various locations detailed hereafter. You can refer to Programming examples for macros illustrating how to run Python interactive console from %PRODUCTNAME . + Programming with Python Scripts Creating a dialog diff --git a/source/text/sbasic/python/python_ide.xhp b/source/text/sbasic/python/python_ide.xhp index 05645cc501..aa81a574c0 100644 --- a/source/text/sbasic/python/python_ide.xhp +++ b/source/text/sbasic/python/python_ide.xhp @@ -22,11 +22,18 @@ python;IDE - integrated development environment python;editor - Setting up an Integrated Development Environment (IDE) for Python +

Setting up an Integrated Development Environment (IDE) for Python

Writing Python macros requires extra configuration steps in order set an IDE of choice. - - Unlike Basic language macros development in %PRODUCTNAME, writing Python macros requires extra configuration steps in order to build your IDE of choice. In return you are provided with flexible design experience built upon your Python developing preferences or habits. Hereafter are IDE setup guidelines that range from beginner to advanced user. + + Unlike Basic language macros development in %PRODUCTNAME, developing Python scripts for %PRODUCTNAME requires to configure an external Integrated Development Environment (IDE). Multiple IDEs are available that range from beginners to advanced Python coders. While using a Python IDE programmers benefit from numerous features such as syntax highlighting, code folding, class browsing, code completion, coding standard enforcement, test driven development, debugging, version control and many more. You can refer to Designing & Developing Python Applications on the Wiki for more in-depth information about the setup of a bridge between your IDE and a running instance %PRODUCTNAME. + +

The APSO Extension

+ The Alternative Python Script Organizer (APSO) extension eases the edition of Python scripts, in particular when embedded in a document. Using APSO you can configure your preferred source code editor and start the integrated Python shell. Extensions exist that help inspect arbitrary UNO objects, refer to Designing & Developing Python Applications for additional details on such extensions. +
+ +
+ diff --git a/source/text/sbasic/python/python_locations.xhp b/source/text/sbasic/python/python_locations.xhp index 24462b698e..eec6a0e852 100644 --- a/source/text/sbasic/python/python_locations.xhp +++ b/source/text/sbasic/python/python_locations.xhp @@ -17,7 +17,7 @@
- Python scripts Organization and Location + Python Scripts Organization and Location The Python script files are stored in the file system, in folders controlled by %PRODUCTNAME. The macros can be stared at installation, user or file level.
@@ -25,13 +25,13 @@

%PRODUCTNAME Macros container

Existing macros in this location (container) were copied by the installation program and are available to every computer user, and any open document can access macros stored the container. You need administrative rights to store or edit macros here. - The LibreOfficeDev Macros container location in the file system depends on the operating system: + The %PRODUCTNAME Macros container location in the file system depends on the operating system: - For Windows, C:\Program Files (x86)\LibreOffice\Basis\share\Scripts\python. + For Windows,
C:\Program Files (x86)\LibreOffice\Basis\share\Scripts\python.
- For Linux and macOS, in $(Installation)/share/Scripts/python. + For Linux and macOS,
$(Installation)/share/Scripts/python.

My Macros

@@ -39,10 +39,10 @@ The My Macros container location is in the user space and depends on the operating system: - For Windows, in C:\Users\current-user\AppData\Roaming\libreoffice\4\user\Scripts\python. + For Windows,
C:\Users\current-user\AppData\Roaming\libreoffice\4\user\Scripts\python.
- For Linux and macOS, in $(HOME)/.config/libreoffice/4/user/Scripts/python. + For Linux and macOS,
$(HOME)/.config/libreoffice/4/user/Scripts/python.

Document macros

@@ -55,5 +55,8 @@ A module is a python file in the library or the container. Create a module adding a file in the container.

Python macros

A macro is a python object in the module. +
+ +
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