From b97f163be7b79bdfe410274d2bb01bd34a33c2b7 Mon Sep 17 00:00:00 2001 From: Rafael Lima Date: Thu, 28 Jul 2022 20:47:09 +0200 Subject: [PATCH] Update bookmarks for python_programming.xhp This patch also fixes all duplicated IDs that existed in this file. Change-Id: I186f54d44a3863e2ead5f8e5ea33d4262e665f46 Reviewed-on: https://gerrit.libreoffice.org/c/help/+/137529 Tested-by: Jenkins Reviewed-by: Alain Romedenne --- .../text/sbasic/python/python_programming.xhp | 47 ++++++++++++------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/source/text/sbasic/python/python_programming.xhp b/source/text/sbasic/python/python_programming.xhp index 96deb86064..9f53dfa60e 100644 --- a/source/text/sbasic/python/python_programming.xhp +++ b/source/text/sbasic/python/python_programming.xhp @@ -11,16 +11,19 @@ Python : Programming with Python - /text/sbasic/python/python_programming.xhp + /text/sbasic/python/python_programming.xhp - Python;Programming - XSCRIPTCONTEXT;Python - XSCRIPTCONTEXT;getComponentContext() - uno.py - uno.py;getComponentContext() + Python;Programming + XSCRIPTCONTEXT;Python + XSCRIPTCONTEXT;getComponentContext + XSCRIPTCONTEXT;getDesktop + XSCRIPTCONTEXT;getDocument + uno.py;getComponentContext + uno.py;getDesktop + uno.py;getDocument

Programming with Python Scripts

@@ -82,6 +85,18 @@ %PRODUCTNAME Basic libraries contain classes, routines and variables, Python modules contain classes, functions and variables. Common pieces of reusable Python or UNO features must be stored in My macros within (User Profile)/Scripts/python/pythonpath. Python libraries help organize modules in order to prevent module name collisions. Import uno.py inside shared modules.
Genuine BASIC UNO facilities can be inferred using uno.py module. Use Python interactive shell to get a complete module description using dir() and help() Python commands. + + uno.py + uno.py;absolutize + uno.py;createUnoStruct + uno.py;fileUrlToSystemPath + uno.py;getClass + uno.py;getComponentContext + uno.py;Enum + uno.py;getConstantByName + uno.py;isInterface + uno.py;systemPathToFileUrl + @@ -231,7 +246,7 @@ - EqualUnoObjects() + EqualUnoObjects() @@ -276,21 +291,21 @@ - desktop = smgr.createInstanceWithContext(DESK , ctx) - doc = desktop.CurrentComponent + desktop = smgr.createInstanceWithContext(DESK , ctx) + doc = desktop.CurrentComponent - ThisComponent + ThisComponent
-

Importing an embedded Module

+

Importing an embedded Module

- Similarly to %PRODUCTNAME Basic that supports browsing and dynamic loading of libraries, Python libraries can be explored and imported on demand. For more information on library containers, visit %PRODUCTNAME Application Programming Interface (API) or download %PRODUCTNAME Software Development Kit (SDK). - Importing a Python document embedded module is illustrated below, exception handling is not detailed: + Similarly to %PRODUCTNAME Basic that supports browsing and dynamic loading of libraries, Python libraries can be explored and imported on demand. For more information on library containers, visit %PRODUCTNAME Application Programming Interface (API) or download %PRODUCTNAME Software Development Kit (SDK). + Importing a Python document embedded module is illustrated below, exception handling is not detailed: - import uno, sys - + import uno, sys + def load_library(library_name: str, module_name=None): """ load library and import module @@ -303,7 +318,7 @@ sys.path.insert(0, url) # doclib takes precedence if module_name: # import if requested return zipimport.zipimporter(url).load_module(module_name) - + def import_embedded_python(): ui = load_library("my_gui",'screen_io') # add <lib> path + import <module> ui.MsgBox(sys.modules.keys())