LibreOffice SymbolLibreOffice Symbol

Stötta oss!

scriptforge module

Så här använder du det här kommandot...

Open Tools - Macros - Macro Manager menu.


scriptforge module holds an extensible collection or scripting resources for LibreOfficeDev to be invoked from Python scripts. A complete description of these resources is available from ScriptForge libraries help page.

Methods

List of Methods in scriptforge module

CreateScriptService

ScriptForge


CreateScriptService

Instantiates ScriptForge resources as "Services". It serves as a generic constructor to all properties methods or classes of ScriptForge services.

Syntax:

CreateScriptService(servicename: str [, arg0, arg1, ...]): svc

Parametrar:

servicename: A ScriptForge service name such as 'ScriptForge.FileSystem', 'SFDialogs.Dialog' or else.

arg0, arg1, ...: Optional parameters with regards to the instantiated service.

Exempel:


      from scriptforge import CreateScriptService as getSvc
      svc = getSvc('ScriptForge.Basic')
	  svc.MsgBox('Hello')
      svc.Dispose()
    

The Dispose method is available in all services and should be called to free up resources after usage.

Symbolen Info

'ScripForge.Basic' service contains dedicated properties and methods that access UNO objects and services, as well as other facilities.


ScriptForge class

Connects to a running LibreOfficeDev service started with the command line. ScriptForge class can bind IDE-based Python scripts to a remote LibreOfficeDev process for debugging purpose.

Syntax:

opt ScriptForge(pipe = 'PIPE2LIBREOFFICE'): obj
opt ScriptForge(hostname = '', port = 0): obj

Pipe and socket connections exclude one another.

Parametrar:

pipe: Named pipe used to start the LibreOfficeDev remote service. Default name is 'PIPE2LIBREOFFICE'.

hostname: '', 'localhost' or the IP address of the machine hosting the remote LibreOfficeDev service.

port: The port number used to start LibreOfficeDev as a service.

Exempel:

Providing LibreOfficeDev was started from the command line as:


      from scriptforge import CreateScriptService as getSvc
      ui = getSvc('ScriptForge.Basic')
      
      def my_script():  # user code goes here
          response = ui.MsgBox('Do you want to continue?',ui.MB_YESNOCANCEL,'A message from Python')
          ui.MsgBox('scriptforge module',ui.MB_OK,response)
      
      g_exportedScripts = (my_script,)  # LibreOffice entry points
      
      if __name__ == "__main__":  # entry point for IDEs
          # from scriptforge import ScriptForge # as session manager
          # ScriptForge(pipe='PIPE2LIBREOFFICE')  # performed in the background
          my_script()
    
Symbolen Tips

To learn more about how to create and execute Python scripts using scriptforge module, read the help page Creating Python Scripts with ScriptForge.


Varningssymbol

All scriptforge methods or identifiers that are prefixed with an underscore character "_" are reserved for internal use. They are not meant be used in Python scripts.