summaryrefslogtreecommitdiff
path: root/source/text/sbasic/python/python_locations.xhp
blob: 4ec027b43ece6ce9657fac48d939e5b8647e3bc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?xml version="1.0" encoding="UTF-8"?>
<helpdocument version="1.0">
    <!--
    * This file is part of the LibreOffice project.
    *
    * This Source Code Form is subject to the terms of the Mozilla Public
    * License, v. 2.0. If a copy of the MPL was not distributed with this
    * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    *
    -->

    <meta>
        <topic id="pythonlocations" indexer="include" status="PUBLISH">
            <title id="tit" xml-lang="en-US">Python Scripts Organization</title>
            <filename>/text/sbasic/python/python_locations.xhp</filename>
        </topic>
    </meta>
    <body>
    <section id="pythonlocation">
        <paragraph id="hd_id391543358231021" role="heading" level="1" xml-lang="en-US"><variable id="pythonlocations1"><link href="text/sbasic/python/python_locations.xhp" name="command_name">Python Scripts Organization and Location</link></variable></paragraph>
        <paragraph id="par_id771543358231022" role="paragraph" xml-lang="en-US">The Python script files are stored in the filesystem, in folders controlled by %PRODUCTNAME. The macros can be started at installation, user or file level.</paragraph>
    </section>
    <h2 id="hd_id911544049584458">Python Script Locations</h2>
        <paragraph id="par_id121551089455774" role="paragraph" xml-lang="en-US">Refer to <link href="text/sbasic/python/python_session.xhp" name="Getting Session Information">Getting Session Information</link> in order to get programmatic access to Python script locations.</paragraph>
    <h3 id="hd_id591544049572647">%PRODUCTNAME Macros container</h3>
    <paragraph role="paragraph" id="par_id261544049064421">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.</paragraph>

    <paragraph role="paragraph" id="par_id861544210028670">The %PRODUCTNAME  Macros container location in the file system depends on the operating system:</paragraph>
    <list type="unordered">
        <listitem>
            <paragraph id="par_id191544210072242"  role="listitem">For <emph>Windows</emph>: <literal>{Installation}\share\Scripts\python</literal>.</paragraph>
        </listitem>
        <listitem>
            <paragraph id="par_id61544210078654"  role="listitem">For <emph>Linux</emph> and <emph>macOS</emph>: <literal>{Installation}/share/Scripts/python</literal>.</paragraph>
        </listitem>
    </list>
    <h3 id="hd_id861544049692222">My Macros</h3>
    <paragraph role="paragraph" id="par_id981544049055996">This container is accessible only by the %PRODUCTNAME user. Any open document can access macros stored the container. Macros in this location are stored in the %PRODUCTNAME user profile.</paragraph>
    <paragraph role="paragraph" id="par_id341544210187846">The My Macros container location is in the user space and depends on the operating system:</paragraph>
    <list type="unordered">
        <listitem>
            <paragraph id="par_id381544210213190"  role="listitem">For <emph>Windows</emph>,<br/><literal>%APPDATA%\LibreOffice\4\user\Scripts\python</literal>.</paragraph>
        </listitem>
        <listitem>
            <paragraph id="par_id691544210219850"  role="listitem">For <emph>Linux</emph> and <emph>macOS</emph>,<br/><literal>$HOME/.config/libreoffice/4/user/Scripts/python</literal>.</paragraph>
        </listitem>
    </list>
    <h3 id="hd_id101544049707712">Document macros</h3>
    <paragraph role="paragraph" id="par_id31544049046497">Document macros are embedded in the document and are accessible only when the document is open.</paragraph>
    <h2 id="hd_id171544049715310">Libraries, Modules and Macros</h2>
    <paragraph role="paragraph" id="par_id181544209916707">Like BASIC macros, Python macros can be organized in libraries, modules and macros.</paragraph>
    <h3 id="hd_id21544209865082">Creating a Python Library</h3>
    <paragraph role="paragraph" id="par_id191544209928221">Libraries are folders in the container tree. To create a library, add a folder in the target container. The library name is the folder name.</paragraph>
    <h3 id="hd_id31544209872869">Creating a Python Module.</h3>
    <paragraph role="paragraph" id="par_id161544209936743">A module is a python file in the library or the container. Create a module adding a file in the container.</paragraph>
    <h3 id="hd_id151544209895574">Python macros</h3>
    <paragraph role="paragraph" id="par_id61544209944591">A macro is a python object in the module.</paragraph>
    <section id="relatedtopics">
        <embed href="text/sbasic/python/python_session.xhp#pythonsession"/>
        <embed href="text/sbasic/python/main0000.xhp#pythonscriptshelp"/>
    </section>
</body>
</helpdocument>