### Full Example: Calc Cell Styling Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/help/calc/format/style/cell.html Demonstrates the complete process of creating a Calc document, applying a style to a cell, and verifying it. Includes setup and cleanup. ```python from __future__ import annotations import uno from ooodev.calc import CalcDoc from ooodev.loader import Lo from ooodev.format.calc.style import StyleCellKind def main() -> int: with Lo.Loader(connector=Lo.ConnectSocket()): doc = CalcDoc.create_doc(visible=True) sheet = doc.sheets[0] Lo.delay(500) doc.zoom_value(400) cell = sheet["A1"] cell.value = "Hello" cell.style_by_name(StyleCellKind.ACCENT_1) name = cell.style_by_name_get() assert name == str(StyleCellKind.ACCENT_1) Lo.delay(1_000) doc.close() return 0 if __name__ == "__main__": SystemExit(main()) ``` -------------------------------- ### Test LibreOffice API Integration Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_poetry_env.html Start a Python interpreter within the activated virtual environment and run a test script to verify the LibreOffice API integration. This example demonstrates loading LibreOffice, creating a Calc document, and writing to a cell. ```python >>> import uno >>> from ooodev.loader import Lo >>> from ooodev.calc import CalcDoc >>> >>> def say_hello(cell_name): ... doc = CalcDoc.from_current_doc() ... sheet = doc.sheets[0] ... sheet[cell_name].value="Hello World!" ... >>> _ = Lo.load_office(Lo.ConnectSocket()) >>> doc = CalcDoc.create_doc(visible=True) >>> say_hello("A1") >>> doc.close() >>> Lo.close_office() ``` -------------------------------- ### Install Project Requirements with Poetry on Linux Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/dev_docs/dev_notes.html After activating the virtual environment, use Poetry to install the project's dependencies. Ensure Poetry is installed on your system. ```bash (.venv) $ poetry install ``` -------------------------------- ### Install Additional Development Packages Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_poetry_env.html Install other development packages, such as `ooo-dev-tools`, into the configured virtual environment using Poetry. ```bash poetry add ooo-dev-tools ``` -------------------------------- ### Install Python venv Package Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_manual_venv.html Installs the 'python3.10-venv' package if the virtual environment creation fails due to it not being installed. ```bash sudo apt install python3.10-venv ``` -------------------------------- ### Install Pip if Missing Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_lo_install_pip.html If pip is not found, use this command to download and install it using the system's Python 3 executable. This ensures pip is available for subsequent package installations. ```bash curl -sSL https://bootstrap.pypa.io/get-pip.py | /usr/bin/python3 - ``` -------------------------------- ### Install LibreOffice Script Provider Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_flatpak_automate_lo.html Installs the necessary apt package to allow scripts to connect to LibreOffice. ```bash sudo apt install libreoffice-script-provider-python ``` -------------------------------- ### Install and Configure oooenv Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_flatpak_automate_lo.html Installs the oooenv package within the activated virtual environment and configures it to use 'uno.py' and 'unohelper.py' for LibreOffice API access. ```bash python -m pip install oooenv ``` ```bash oooenv cmd-link -a ``` -------------------------------- ### Install ooo-dev-tools Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_linking_paths.html Installs the 'ooo-dev-tools' package, which provides tools and typing support for LibreOffice API development within the virtual environment. ```bash pip install ooo-dev-tools ``` -------------------------------- ### Install pip Package for LibreOffice Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_lo_install_pip.html Install a Python package, such as 'ooo-dev-tools', using pip and the LibreOffice-specific Python executable. This command defaults to user installation, which is generally recommended. ```bash $ /usr/bin/python3 -m pip install ooo-dev-tools Defaulting to user installation because normal site-packages is not writeable Collecting ooo-dev-tools Using cached ooo_dev_tools-0.11.7-py3-none-any.whl (2.2 MB) Collecting lxml>=4.9.2 (from ooo-dev-tools) Using cached lxml-4.9.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (7.1 MB) Collecting ooouno>=2.1.2 (from ooo-dev-tools) Using cached ooouno-2.1.2-py3-none-any.whl (9.8 MB) Collecting types-unopy>=1.2.3 (from ooouno>=2.1.2->ooo-dev-tools) Using cached types_unopy-1.2.3-py3-none-any.whl (5.2 MB) Collecting typing-extensions<5.0.0,>=4.6.2 (from ooouno>=2.1.2->ooo-dev-tools) Using cached typing_extensions-4.6.3-py3-none-any.whl (31 kB) Collecting types-uno-script>=0.1.1 (from types-unopy>=1.2.3->ooouno>=2.1.2->ooo-dev-tools) Using cached types_uno_script-0.1.1-py3-none-any.whl (9.3 kB) Installing collected packages: typing-extensions, types-uno-script, lxml, types-unopy, ooouno, ooo-dev-tools Successfully installed lxml-4.9.2 ooo-dev-tools-0.11.7 ooouno-2.1.2 types-uno-script-0.1.1 types-unopy-1.2.3 typing-extensions-4.6.3 ``` -------------------------------- ### Install oooenv as Development Dependency Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/windows_poetry_env.html Install the oooenv package into the virtual environment as a development dependency using Poetry. ```powershell poetry add oooenv --group=dev ``` -------------------------------- ### Test Pip Package Installation in LibreOffice Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_install_pkg_zaz_pip.html This code snippet demonstrates how to test an installed pip package by writing 'Hello World!' to a LibreOffice Writer document using the APSO console. Ensure the ooo-dev-tools package is installed first. ```python APSO python console [LibreOffice] 3.10.11 (main, Nov 10 2011, 15:00:00) [GCC 12.2.0] Type "help", "copyright", "credits" or "license" for more information. >>> from ooodev.write import WriteDoc >>> def say_hello(): ... doc = WriteDoc.from_current_doc() ... cursor = doc.get_cursor() ... cursor.append_para(text="Hello World!") ... >>> say_hello() >>> ``` -------------------------------- ### Starting LibreOffice Flatpak via subprocess Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_flatpak_automate_lo.html This snippet shows how to start LibreOffice Flatpak using `subprocess.Popen`. It's important to use `shell=True` for this command. Note the use of `socket` for accepting connections. ```python # is it important to use shell=True import os from subprocess import Popen Popen(f'flatpak run org.libreoffice.LibreOffice/x86_64/stable --invisible --norestore --nofirststartwizard --nologo --accept="socket,host=localhost,port=2002,tcpNoDelay=1;urp;" --display {os.getenv("DISPLAY")}', shell=True) ``` -------------------------------- ### Install Pip using curl (Cmd Shell) Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/windows_manual_venv.html In a Command Prompt, use `curl` to download `get-pip.py`, then pipe its content to the virtual environment's Python interpreter to install pip. ```cmd curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && type get-pip.py | python.exe - ``` -------------------------------- ### Install Poetry on Windows Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/poetry_env.html Execute this command in PowerShell to install Poetry on Windows systems. If Python was installed from the Microsoft Store, use 'python' instead of 'py'. ```powershell (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py - ``` -------------------------------- ### Verify Poetry Installation Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/poetry_env.html Run this command to check if Poetry has been installed successfully and to view its version. ```bash poetry --version ``` -------------------------------- ### Install ooo-dev-tools Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_flatpak_automate_lo.html Installs the ooo-dev-tools package, which is required for automating LibreOffice and has a version dependency. ```bash python -m pip install ooo-dev-tools ``` -------------------------------- ### Testing installed Pip package Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/windows_install_pkg_zaz_pip.html This code snippet demonstrates how to test an installed pip package by writing 'Hello World!' to a LibreOffice Writer document using the ooodev library. ```python APSO python console [LibreOffice] 3.8.16 (default, Apr 28 2023, 09:24:49) [MSC v.1929 32 bit (Intel)] Type "help", "copyright", "credits" or "license" for more information. >>> from ooodev.loader.lo import Lo >>> from ooodev.write import WriteDoc >>> >>> def say_hello(): ... doc = WriteDoc.from_current_doc() ... cursor = doc.get_cursor() ... cursor.append_para(text="Hello World!") ... >>> say_hello() >>> ``` -------------------------------- ### Install Project Requirements with Poetry on Windows Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/dev_docs/dev_notes.html After activating the virtual environment on Windows, use Poetry to install project dependencies. This command is run within the activated environment. ```powershell (.venv) PS C:\python_ooo_dev_tools> poetry install ``` -------------------------------- ### Install oooenv for LibreOffice API Access Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_poetry_env.html Install the `oooenv` package within the activated virtual environment. This package provides `uno.py` and `unohelper.py` for interacting with the LibreOffice API. ```bash poetry add --group=dev oooenv ``` -------------------------------- ### Install pip using get-pip.py Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/windows_portable_install_pip.html Download the get-pip.py script and execute it using the LibreOffice Portable's Python interpreter to install pip. Warnings about script locations can be ignored. ```powershell (Invoke-WebRequest -Uri https://bootstrap.pypa.io/get-pip.py -UseBasicParsing).Content | .\python.exe - ``` -------------------------------- ### Install Pip using Invoke-WebRequest (PowerShell) Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/windows_manual_venv.html With the virtual environment activated, use PowerShell's `Invoke-WebRequest` to download `get-pip.py` and execute it with the environment's Python interpreter to install pip. ```powershell Invoke-WebRequest -Uri https://bootstrap.pypa.io/get-pip.py -UseBasicParsing).Content | python.exe - ``` -------------------------------- ### Install Poetry on macOS/Linux Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/poetry_env.html Execute this command in Terminal or PowerShell to install Poetry on macOS and Linux systems. ```bash curl -sSL https://install.python-poetry.org | python3 - ``` -------------------------------- ### Install ooo-dev-tools using Poetry Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/windows_poetry_env.html Use poetry to add the 'ooo-dev-tools' package to your project. This command installs the package and updates the pyproject.toml file. ```bash poetry add ooo-dev-tools ``` -------------------------------- ### Install OOOENV Package Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_manual_venv.html Installs the 'oooenv' package within the activated virtual environment. This package helps configure the environment for LibreOffice API access. ```bash python -m pip install oooenv ``` -------------------------------- ### Install pip using get-pip.py Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/windows_lo_install_pip.html Download the get-pip.py script and execute it using LibreOffice's Python interpreter to install pip. This command fetches the script and pipes its content directly to the Python executable. ```powershell (Invoke-WebRequest -Uri https://bootstrap.pypa.io/get-pip.py -UseBasicParsing).Content | .\python.exe - ``` -------------------------------- ### Test Installed Package with a Script Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/windows_lo_install_pip.html Execute a Python script using LibreOffice's Python interpreter to test the installed 'ooo-dev-tools' package. This script loads LibreOffice, creates a new Writer document, appends 'Hello World!', and then closes the document and LibreOffice. ```python >.\python.exe Python 3.8.16 (default, Apr 28 2023, 02:01:33) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from ooodev.loader import Lo >>> from ooodev.write import WriteDoc >>> >>> def say_hello(): ... doc = WriteDoc.from_current_doc() ... cursor = doc.get_cursor() ... cursor.append_para(text="Hello World!") ... >>> _ = Lo.load_office(Lo.ConnectSocket()) >>> doc = WriteDoc.create_doc(visible=True) >>> say_hello() >>> doc.close() >>> Lo.close_office() True >>> ``` -------------------------------- ### Verify Pip Installation (Cmd Shell) Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/windows_manual_venv.html Confirm the pip installation and its path within the active virtual environment by running this command in a Command Prompt. ```cmd (.venv) D:\tmp\manual>python -m pip --version ``` -------------------------------- ### Install ooo-dev-tools Package Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/windows_lo_install_pip.html Install the 'ooo-dev-tools' package using pip. This package is used for testing and interacting with LibreOffice applications via Python. ```powershell >.\python.exe -m pip install ooo-dev-tools ``` -------------------------------- ### Start LibreOffice with Logging Options Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/version/version_hist.html Illustrates how to initialize LibreOffice with specific logging options, such as setting the log level during the loading process. This is useful for debugging startup issues. ```python from __future__ import annotations from ooodev.io.log import logging as logger from ooodev.calc import CalcDoc from ooodev.loader import Lo from ooodev.loader.inst.options import Options def main(): loader = Lo.load_office(connector=Lo.ConnectPipe(), opt=Options(log_level=logging.DEBUG)) doc = None try: doc = CalcDoc.create_doc(loader=loader, visible=True) logger.debug("Hello World") # do other work finally: if doc: doc.close() Lo.close_office() ``` -------------------------------- ### Get LibreOffice FlatPak Python Version Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_flatpak_lo_pip.html Start FlatPak LibreOffice and open the APSO extension to access the Python console and determine the installed Python version. ```text APSO python console [LibreOffice] 3.10.11 (main, Nov 10 2011, 15:00:00) [GCC 12.2.0] Type "help", "copyright", "credits" or "license" for more information. >>> ``` -------------------------------- ### Build HTML Documentation (Linux) Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/dev_docs/dev_notes.html Execute this command within the ./docs directory after activating the virtual environment to build HTML documentation. ```bash (.venv) $ make html ``` -------------------------------- ### Get LibreOffice Python Version (PowerShell) Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/windows_manual_venv.html Use this PowerShell command to retrieve the version of the Python interpreter bundled with your LibreOffice installation. This version is needed for configuring the virtual environment. ```powershell &"C:\Program Files\LibreOffice\program\python.exe" --version ``` -------------------------------- ### Get LibreOffice Python Executable Path Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_lo_install_pip.html Use the APSO extension in LibreOffice to find the exact Python executable path that LibreOffice is using. This is crucial for ensuring compatibility when installing packages. ```python >>> import sys >>> sys.executable '/usr/bin/python3' >>> ``` -------------------------------- ### Build HTML Documentation (Windows) Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/dev_docs/dev_notes.html Execute this command within the ./docs directory after activating the virtual environment to build HTML documentation. ```powershell PS C:\python_ooo_dev_tools\docs> make html ``` -------------------------------- ### Get LibreOffice Python Version (Cmd Shell) Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/windows_manual_venv.html Execute this command in a Windows Command Prompt to find the version of the Python interpreter used by LibreOffice. This information is crucial for the virtual environment setup. ```cmd "C:\Program Files\LibreOffice\program\python.exe" --version ``` -------------------------------- ### Initialize Poetry Project Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/windows_poetry_env.html Initialize a new Poetry project in the current directory. This will create a pyproject.toml file. ```powershell cd D:\tmp\project poetry init ``` -------------------------------- ### Create Project Directory Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_manual_venv.html Creates a new directory for your project and navigates into it. ```bash mkdir ~/myproject cd ~/myproject ``` -------------------------------- ### Verify pip Installation Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/windows_lo_install_pip.html Check the installed version of pip to confirm a successful installation. This command ensures that pip is recognized by LibreOffice's Python environment. ```powershell >.\python.exe -m pip --version ``` -------------------------------- ### Create Project Directory and Virtual Environment Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_flatpak_automate_lo.html Sets up a new project directory and creates a Python virtual environment using a specific Python version. ```bash $ mkdir ~/my-project cd ~/my-project ``` ```bash /usr/bin/python3.10 -m venv .venv ``` -------------------------------- ### Initialize Poetry Project Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_poetry_env.html Use `poetry init` to create a `pyproject.toml` file for your project. This command interactively guides you through setting up project metadata and dependencies. ```bash poetry init ``` -------------------------------- ### Get Unit Length Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/src/units/index.html Gets the instance unit length. ```APIDOC ## get_unit_length() -> UnitLength ### Description Gets instance unit length. ### Returns Instance unit length `UnitLength.MM`. ### Return Type UnitLength ``` -------------------------------- ### Run Local HTTP Server for Docs (Linux) Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/dev_docs/dev_notes.html Start a local web server in a separate terminal to view documentation by running this script. ```bash (.venv) $ python cmds/run_http.py ``` -------------------------------- ### Get Value in Inches Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/src/units/index.html Gets the instance value in inch units. ```APIDOC ## get_value_inch() -> float ### Description Gets instance value in `in` (inch) units. ### Returns Value in `in` units. ### Return Type float ``` -------------------------------- ### Create Project Directory Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_poetry_env.html Create a new directory for your project and navigate into it. This sets up the workspace for your Poetry project. ```bash mkdir ~/myproject cd ~/myproject ``` -------------------------------- ### Get Value in Centimeters Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/src/units/index.html Gets the instance value converted to centimeter units. ```APIDOC ## get_value_cm() -> float ### Description Gets instance value converted to `cm` units. ### Returns Value in `cm` units. ### Return Type float ``` -------------------------------- ### Get Value in AppFont Units Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/src/units/index.html Gets the instance value in AppFont units. ```APIDOC ## get_value_app_font(kind: Union[PointSizeKind, int]) -> float ### Description Gets instance value in `AppFont` units. ### Parameters #### Path Parameters - **kind** (PointSizeKind or int) - The kind of `AppFont` to use. ### Returns Value in `AppFont` units. ### Note AppFont units have different values when converted. This is true even if they have the same value in `AppFont` units. `AppFontX(10)` is not equal to `AppFontY(10)` when they are converted to different units. `Kind` when `int` is used, the value must be one of the following: * `0` is `PointSizeKind.X`, * `1` is `PointSizeKind.Y`, * `2` is `PointSizeKind.WIDTH`, * `3` is `PointSizeKind.HEIGHT`. ### Hint * `PointSizeKind` can be imported from `ooodev.utils.kind.point_size_kind`. ``` -------------------------------- ### Get Unit Length Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/_modules/ooodev/units/unit_cm.html Gets the instance unit length, which is always UnitLength.CM. ```python @staticmethod def get_unit_length() -> UnitLength: """ Gets instance unit length. Returns: UnitLength: Instance unit length ``UnitLength.CM``. """ return UnitLength.CM ``` -------------------------------- ### Invoke Basic Script from Python Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/version/version_hist.html Demonstrates how to get a reference to a Basic script using `ooodev.macro.script.basic.Basic` and invoke it with arguments. The script is expected to return a value. ```python from ooodev.macro.script.basic import Basic def r_trim(input: str, remove: str = " ") -> str: script = Basic.get_basic_script(macro="RTrimStr", module="Strings", library="Tools", embedded=False) res = script.invoke((input, remove), (), ()) return res[0] result = r_trim("hello ") assert result == "hello" ``` -------------------------------- ### Get Value in 1/1000th Inches Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/src/units/index.html Gets the instance value in 1/1000th inch units. ```APIDOC ## get_value_inch1000() -> int ### Description Gets instance value in `1/1000th inch` units. ### Returns Value in `1/1000th inch` units. ### Return Type int ``` -------------------------------- ### Get Value in 1/100th Inches Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/src/units/index.html Gets the instance value in 1/100th inch units. ```APIDOC ## get_value_inch100() -> int ### Description Gets instance value in `1/100th inch` units. ### Returns Value in `1/100th inch` units. ### Return Type int ``` -------------------------------- ### Create and Activate Virtual Environment Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_linking_paths.html Sets up a Python virtual environment for project isolation and activates it for use. ```bash python3 -m venv venv source venv/bin/activate ``` -------------------------------- ### Get Value in 1/10th Inches Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/src/units/index.html Gets the instance value in 1/10th inch units. ```APIDOC ## get_value_inch10() -> int ### Description Gets instance value in `1/10th inch` units. ### Returns Value in `1/10th inch` units. ### Return Type int ``` -------------------------------- ### Run Local HTTP Server for Docs (Windows) Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/dev_docs/dev_notes.html Start a local web server in a separate terminal to view documentation by running this script. ```powershell PS C:\python_ooo_dev_tools> python .\cmds\run_http.py ``` -------------------------------- ### Connect to Snap LibreOffice Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_manual_venv_snap.html Establish a connection to a snap-installed LibreOffice instance. This is necessary when LibreOffice is installed via Snap and requires specific path configurations. ```python Lo.ConnectSocket(soffice="/snap/bin/libreoffice", env_vars={"PYTHONPATH": py_pth}) ``` -------------------------------- ### UnitInch10 Get Value in MM100 Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/_modules/ooodev/units/unit_inch10.html Gets the instance value converted to 1/100th of a millimeter (mm100) units. ```python return UnitConvert.convert(num=self.value, frm=UnitLength.IN10, to=UnitLength.MM100) ``` -------------------------------- ### Test Virtual Environment Import uno on Windows Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/dev_docs/dev_notes.html Verify that the virtual environment is set up correctly by attempting to import the `uno` module in the Python interpreter. No import error indicates a successful setup. ```python PS C:\python_ooo_dev_tools> .\.venv\scripts\activate (.venv) PS C:\python_ooo_dev_tools> python Python 3.8.10 (default, Mar 23 2022, 15:43:48) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import uno >>> ``` -------------------------------- ### Verify LibreOffice Environment Setup on Windows Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/dev_docs/dev_notes.html Check if the virtual environment is correctly configured for LibreOffice on Windows by running `oooenv env -u`. A successful output indicates the UNO environment is active. ```powershell (.venv) PS C:\python_ooo_dev_tools> oooenv env -u UNO Environment ``` -------------------------------- ### Get Value in PX - UnitInch1000 Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/_modules/ooodev/units/unit_inch1000.html Gets the instance value converted to pixels (px). Requires UnitConvert to be imported. ```python def get_value_px(self) -> float: """ Gets instance value in ``px`` (pixel) units. Returns: int: Value in ``px`` units. """ return UnitConvert.convert(num=self.value, frm=UnitLength.IN1000, to=UnitLength.PX) ``` -------------------------------- ### Get Value in PT - UnitInch1000 Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/_modules/ooodev/units/unit_inch1000.html Gets the instance value converted to points (pt). Requires UnitConvert to be imported. ```python def get_value_pt(self) -> float: """ Gets instance value converted to ``pt`` (point) units. Returns: int: Value in ``pt`` units. """ return UnitConvert.convert(num=self.value, frm=UnitLength.IN1000, to=UnitLength.PT) ``` -------------------------------- ### Get Value in MM - UnitInch1000 Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/_modules/ooodev/units/unit_inch1000.html Gets the instance value converted to millimeters (mm). Requires UnitConvert to be imported. ```python def get_value_mm(self) -> float: """ Gets instance value converted to ``mm`` units. Returns: int: Value in ``mm`` units. """ return UnitConvert.convert(num=self.value, frm=UnitLength.IN1000, to=UnitLength.MM) ``` -------------------------------- ### Get Value in CM - UnitInch1000 Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/_modules/ooodev/units/unit_inch1000.html Gets the instance value converted to centimeters (cm). Requires UnitConvert to be imported. ```python def get_value_cm(self) -> float: """ Gets instance value converted to ``cm`` units. Returns: int: Value in ``cm`` units. """ return UnitConvert.convert(num=self.value, frm=UnitLength.IN1000, to=UnitLength.CM) ``` -------------------------------- ### Get LibreOffice Temp Directory Path Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/version/version_hist.html Access the Lo.tmp_dir property to get the LibreOffice temporary directory as a pathlib.Path object. ```python from ooodev.loader import Lo print(str(Lo.tmp_dir)) ``` -------------------------------- ### Initialize ApplicationAppearance Theme Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/_modules/ooodev/theme/theme.html Initializes the theme with a specified name or uses the current LibreOffice theme if none is provided. Raises a ValueError if no theme name can be found or if an invalid theme name is specified and automatic theme detection is off. ```python theme_name = "" # or ThemeKind.AUTOMATIC theme = ApplicationAppearance(theme_name=theme_name) ``` -------------------------------- ### Get Value in 1/100th MM - UnitInch1000 Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/_modules/ooodev/units/unit_inch1000.html Gets the instance value in 1/100th of a millimeter (mm100). Requires UnitConvert to be imported. ```python def get_value_mm100(self) -> int: """ Gets instance value in ``1/100th mm`` units. Returns: int: Value in ``1/100th mm`` units. """ return round(UnitConvert.convert(num=self.value, frm=UnitLength.IN1000, to=UnitLength.MM100)) ``` -------------------------------- ### Navigate to Project Directory Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/windows_poetry_env.html Change the current directory to your project's location before creating the virtual environment. ```powershell cd D:\tmp\project ``` -------------------------------- ### Install ooo-dev-tools using pip Source: https://python-ooo-dev-tools.readthedocs.io/en/latest Install the ooo-dev-tools package using pip. Support for Python 3.7 was dropped in version 0.10.0. ```bash pip install ooo-dev-tools ``` -------------------------------- ### Import Lo from ooodev.loader.lo Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/version/version_hist.html Demonstrates the correct import path for the Lo class from the ooodev.loader.lo module. ```python from ooodev.loader.lo import Lo ``` -------------------------------- ### Configure Virtual Environment with OOOENV Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/linux_manual_venv.html Uses the 'oooenv' command-line tool to automatically configure the virtual environment, enabling access to 'uno.py' and 'unohelper.py'. ```bash oooenv cmd-link -a ``` -------------------------------- ### Verify Pip Installation (PowerShell) Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/windows_manual_venv.html After installing pip, verify its version and location within the activated virtual environment using this PowerShell command. ```powershell (myproject_3.8.16) PS D:\tmp\manual> python -m pip --version ``` -------------------------------- ### Install Specific Python Version with pyenv Source: https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/windows_poetry_env.html Install a compatible Python version (e.g., 3.8.10) using pyenv. This version will be used for the virtual environment. ```powershell pyenv install 3.8.10 ```