scripting libo python macros - libreoffice · agenda scripting framework why python ? – srce...

35
Scripting LibO Python Macros Macros Well Kept Secrets Alain Romedenne LibreOfficiant sfr fr Almería | 10-13 Sept. 2019

Upload: others

Post on 12-Jun-2020

51 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

Scripting LibOPython Macros

Macros Well Kept Secrets

Alain RomedenneLibreOfficiant sfr fr

Almería | 10-13 Sept. 2019

Page 2: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

Agenda

● Scripting Framework● Why Python ?

– Srce Explorer, Syntax Hiliting, Code Completion, Debugging,

– Coding Guidelines, Test-Driven Dev, Version Control

● Walkthrough Geany, PyZo, PyCharm● Extension: APSO - JMZ

– Xray by BM, Mri by Hanya

● IDEs– Projects Setup

● Scripting Python Macros– Help, Libraries & Modules– Programming Basics– Dialogs, Listeners, Monitors– X-Scripting

● Q & A

Page 3: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

Macros Scripting Framework

➔ Python– In 2008

➔ Basic / VBA– *Office legacy– In 2004

➔ API

BeanShellJavaScript

C++JavaPython

Page 4: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

Agenda

● Scripting Framework● Why Python ?

– Srce Explorer, Syntax Hiliting, Code Completion, Debugging,

– Coding Guidelines, Test-Driven Dev, Version Control

● Walkthrough Geany, PyZo, PyCharm● Extension: APSO - JMZ

– Xray by BM, Mri by Hanya

● IDEs– Projects Setup

● Scripting Python Macros– Help, Libraries & Modules– Programming Basics– Dialogs, Listeners, Monitors– X-Scripting

● Q & A

Page 5: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

why Python?

✔ Source explorer✔ Syntax Hiliting✔ Code completion✔ Debugging / REPL✔ Coding guidelines

PEP✔ Test-driven

development✔ Version control

➔ Extensions Mri, Xray APSO

➔ IDEs➔ Python shell

REPL➔ IDE_utils➔ Geany, PyZo,

PyCharm

Page 6: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

Python console

Page 7: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

IDEs

OSs Languages FOSS

Geany Gnu/Linux *BSDMacOSAIXSolaris Windows

43 yes

PyCharm Gnu/LinuxMacOSWindows

english no

PyZo LinuxOS XWindows

10 yesAptana

Liclipse

PyDev for Eclipse

Page 8: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

IDLE: class browser, syntax hiliting

Page 9: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

Agenda

● Scripting Framework● Why Python ?

– Srce Explorer, Syntax Hiliting, Code Completion, Debugging,

– Coding Guidelines, Test-Driven Dev, Version Control

● Walkthrough Geany, PyZo, PyCharm● Extension: APSO - JMZ

– Xray by BM, Mri by Hanya

● IDEs– Projects Setup

● Scripting Python Macros– Help, Libraries & Modules– Programming Basics– Dialogs, Listeners, Monitors– X-Scripting

● Q & A

Page 10: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

Geany: srce explorer, syntax hiliting, code folding

Page 11: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

PyCharm: various explorers, syntax hiliting, code folding

Page 12: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

Geany: code completion

Page 13: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

PyCharm: code completion

Page 14: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

PyZo: debugging

Page 15: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

PyCharm: debugging

Page 16: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

Geany, PyCharm: Unit Testing

Page 17: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

Pycharm: PEP compliance

Page 18: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

PyCharm: Versioning

Page 19: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

Agenda

● Scripting Framework● Why Python ?

– Srce Explorer, Syntax Hiliting, Code Completion, Debugging,

– Coding Guidelines, Test-Driven Dev, Version Control

● Walkthrough Geany, PyZo, PyCharm● Extension: APSO - JMZ

– Xray by BM, Mri by Hanya

● IDEs– Projects Setup

● Scripting Python Macros– Help, Libraries & Modules– Programming Basics– Dialogs, Listeners, Monitors– X-Scripting

● Q & A

Page 20: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

Altern. Python Script Orgzer

More although..

..Less

Page 21: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

APSO: interactive console

Read Evaluate Print Loop

Page 22: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

APSO: debug window

see also Mri, Xray

Page 23: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

Agenda

● Scripting Framework● Why Python ?

– Srce Explorer, Syntax Hiliting, Code Completion, Debugging,

– Coding Guidelines, Test-Driven Dev, Version Control

● Walkthrough Geany, PyZo, PyCharm● Extension: APSO - JMZ

– Xray by BM, Mri by Hanya

● IDEs– Projects Setup

● Scripting Python Macros– Help, Libraries & Modules– Programming Basics– Dialogs, Listeners, Monitors– X-Scripting

● Q & A

Page 24: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

IDEs: Setup

Geany

Pyzo

PyCharm

Page 25: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

IDEs: Geany projects setup

Page 26: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

IDEs: PyZo shell configurations

Page 27: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

IDEs: PyCharm project interpreters

Debugging Python & Basic altogether

Page 28: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

Agenda

● Scripting Framework● Why Python ?

– Srce Explorer, Syntax Hiliting, Code Completion, Debugging,

– Coding Guidelines, Test-Driven Dev, Version Control

● Walkthrough Geany, PyZo, PyCharm● Extension: APSO - JMZ

– Xray by BM, Mri by Hanya

● IDEs– Projects Setup

● Scripting Python Macros– Help, Libraries & Modules– Programming Basics– Dialogs, Listeners, Monitors– X-Scripting

● Q & A

Page 29: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

Scripting: API help

● LibreOffice Helplocal / online

● API documentation

Software Developer Kit

● Python Interactive Console (REPL)

● Forums

Page 30: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

Scripting: module/library

● Programming Python Scripts

● Standalone module: XSCRIPTCONTEXT● Shared module: import uno● Xlating Basic 2 Python

Page 33: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

Scripting: X-Languages● Python to Basic MsgBox, InputBox other use case?

● Basic to Python Std modules cmath, datetime, json, math, net, re,

unittest e.g. python.os.Filelen - demo

● Python/Basic to JavaScript..you name it..

Page 35: Scripting LibO Python Macros - LibreOffice · Agenda Scripting Framework Why Python ? – Srce Explorer, Syntax Hiliting, Code Completion, Debugging, – Coding Guidelines, Test-Driven

ThanksHappy Python!

Q & A

come to discussPython IDE simple enablement (for *Office) using IDE_utilsLibreOffice Basic Hidden Gems