Python: Opening a Dialog/text/sbasic/python/python_dialogs.xhpPython;dialogsdialog box;Pythondialogs;Python
Opening a Dialog in Python
%PRODUCTNAME static dialogs are created with the Dialog editor and are stored in varying places according to their personal (My Macros), shared (%PRODUCTNAME Macros) or document-embedded nature. In reverse, dynamic dialogs are constructed at runtime, from on Basic or Python scripts, or using any other %PRODUCTNAME supported language for that matter. Opening static dialogs with Python is illustrated herewith. Exception handling and internationalization are omitted for clarity.
The example below opens a newly edited Dialog1 dialog from a document with menu:# -*- coding: utf-8 -*-from __future__ import unicode_literalsdef 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 an example of Python dynamic dialogs.