Python script In LO not showing in Python Library

My system.
Description: Ubuntu 23.04
Release: 23.04
Codename: lunar
LibreOffice 7.5.5.2 50(Build:2)

geany 1.38 (built on 2021-10-14 with GTK 3.24.30, GLib 2.68.4)
Python 3.11.4

My problem: I have written scripts in Geany called Weekly_Update2 and saved it in
/home/yodap/.config/libreoffice/4/user/Scripts/python/PythonLibray/.

I can see it in that folder:

But while the Module is there when I go in through LO, I cannot execute the script…as it does not show:

image

Other scripts which I have recently written e.g. Tool_Fill.

When I tried to save the script in Geany, this is what I get?

Please what am I not understanding?

To execute from LO-GUI you dont need # 2. Connect … →remove that Block of code.
wrap # 1. load JSON dat , # 3. Open the new … and # 4. Import … into a function-definition, so the function becomes Visibility from GUI.

for example like:

import json
import uno
from pathlib import Path

def import_from_json(*_):
    with open("temp_data.json") as file: #relative path is bad!
        data = json.load(file)
    desktop = XSCRIPTCONTEXT.getDesktop()
    doc_path = Path("/path/to/your/stocks-2x.ods")
    uri = doc_path.as_uri()
    document = desktop.loadComponentfromURL( uri, "_blank", 0, () )
    inputsheet = document.Sheets['Inputsheet']
    #4 is ugly you probably should use a cursor 
    cursor = inputsheet.createCursor()
    cursor.collapseToSize(len(data[0]), len(data))
    cursor.DataArray = data
1 Like

Thank you so much, that worked a treat.

Just for the record…what caused the previous version not to show in the GUI?

There was no function-definition!!

1 Like

Thank you…am still learning!

I have a similar problem under Windows 10, The macro dialog does not open for a new python script.

Nobody can help with this Information…
Show the code, tell us how (apso? ) and where you install!

AMDG
Please see updated request.
JRBreton