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())