Is is possible to register a form control event from external script?

@Rod007 Demonstrates here how to register an event for a control in Basic.

I have a scritp in python that adds a form and controls to a Calc Spreadsheet.
I want to register the form controls with methods in the same python file that was run to start the whole process. Is this possible or must the python code exist in a LibreOffice Known Location such as Standard library or in the document?

So in short how would I make a button click run a method in my code without using event handlers.
Event handlers seem to have a bug in Calc.

https://wiki.openoffice.org/w/index.php?title=Documentation/DevGuide/Forms/Scripting_and_Events

ScriptCode: Specifies which script code to call. In case of ScriptType being StarBasic , this must specify a Basic procedure or function, either within the application-wide code repository, or within the document which the form component belongs to. In the first case, the script code starts with "application: ", else with "document: ".

This seems to suggest it is not possible for other location such as C:\Projects\my_project\calc_form.py

Yes…

https://wiki.documentfoundation.org/Documentation/DevGuide/Scripting_Framework#Scripting_Framework_URI_Specification

They seem to all indicate that it is not possible. I see only Known Locations.

LOCPARAM

  • script in a library of My Macros : user
  • script in a library of OpenOffice Macros : share
  • script in an extension installed for the current user : user:uno_packages
  • script in an extension installed for all users : share:uno_packages
  • script in a library of the document that calls the script : document

I am wanting to register an event in an external python file.
A python file that acutally starts Calc and builds the form.
For example the file might be C:\Projects\my_project\calc_form.py
and the method might be calc_form.py$on_button_clicked(*args)

Would it be possible to register C:\Projects\my_project\calc_form.py$on_button_clicked and if so what is the syntax for this?

No. And I think, it is unlikely to happen - it would be another security problem…

Thanks for clarifying. As I suspected.