LibreOffice 7.3 Help
Statische dialoogvensters van LibreOffice worden gecreëerd met de Dialoogbewerker en worden opgeslagen op verschillende plaatsen in overeenstemming met hun persoonlijke (Mijn macro’s), gedeelde (LibreOffice-macro’s) of in het document ingebedde aard. Omgekeerd, dynamische dialoogvensters worden tijdens het uitvoeren geconstrueerd, van BASIC- of Python-scripts, of door gebruik te maken van een andere door LibreOffice ondersteunde taal. Het openen van statische dialoogvensters met Python wordt hierbij gedemonstreerd. Het omgaan met uitzonderingen en internationalisering worden weggelaten voor de helderheid.
The examples below open Access2Base Trace console or the imported TutorialsDialog dialog with menu:
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
def consoleDlg():
ctx =XSCRIPTCONTEXT.getComponentContext()
smgr = ctx.getServiceManager()
dp = smgr.createInstanceWithContext("com.sun.star.awt.DialogProvider", ctx)
dlg = dp.createDialog( "vnd.sun.star.script:Access2Base.dlgTrace?location=application")
dlg.execute()
dlg.dispose()
def tutorDialog():
ctx =XSCRIPTCONTEXT.getComponentContext()
smgr = ctx.getServiceManager()
dp = smgr.createInstanceWithContext("com.sun.star.awt.DialogProvider", ctx)
dlg = dp.createDialog("vnd.sun.star.script:Standard.TutorialsDialog?location=application")
dlg.execute()
dlg.dispose()
g_exportedScripts = (consoleDlg, tutorDialog)
The example below opens a newly edited Dialog1 dialog from a document with menu:
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
def docDialog():
""" Display a doc-based dialog """
model = XSCRIPTCONTEXT.getDocument()
smgr = XSCRIPTCONTEXT.getComponentContext().ServiceManager
dp = smgr.createInstanceWithArguments( "com.sun.star.awt.DialogProvider", (model,))
dlg = dp.createDialog( "vnd.sun.star.script:Standard.Dialog1?location=document")
dlg.execute()
dlg.dispose()
g_exportedScripts = (docDialog,)
Refer to msgbox.py in {installation}/program/ directory for Python dynamic dialog examples.