summaryrefslogtreecommitdiffstats
path: root/helpcontent2/source/text/sbasic/python/python_dialogs.xhp
diff options
context:
space:
mode:
Diffstat (limited to 'helpcontent2/source/text/sbasic/python/python_dialogs.xhp')
-rw-r--r--helpcontent2/source/text/sbasic/python/python_dialogs.xhp75
1 files changed, 75 insertions, 0 deletions
diff --git a/helpcontent2/source/text/sbasic/python/python_dialogs.xhp b/helpcontent2/source/text/sbasic/python/python_dialogs.xhp
new file mode 100644
index 000000000..7f728b495
--- /dev/null
+++ b/helpcontent2/source/text/sbasic/python/python_dialogs.xhp
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<helpdocument version="1.0">
+ <!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ -->
+ <meta>
+ <topic id="text/sbasic/python/Python_Dialog">
+ <title id="tit" xml-lang="en-US">Opening a Dialog with Python</title>
+ <filename>/text/sbasic/python/python_dialogs.xhp</filename>
+ </topic>
+ </meta>
+ <body>
+ <bookmark branch="index" id="N0334">
+ <bookmark_value>Python;dialogs</bookmark_value>
+ <bookmark_value>dialog box;Python</bookmark_value>
+ <bookmark_value>dialogs;Python</bookmark_value>
+ </bookmark>
+ <section id="pythondialog1">
+ <h1 id="N0336"><variable id="pythondialog"><link href="text/sbasic/python/python_dialogs.xhp" name="command_name">Opening a Dialog with Python</link></variable></h1>
+ </section>
+ <paragraph role="paragraph" id="N0337">%PRODUCTNAME static dialogs are created with the <link href="text/sbasic/guide/create_dialog.xhp" name="dialog editor">Dialog editor</link> 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 Basic or Python scripts, or using any other <link href="text/shared/guide/scripting.xhp">%PRODUCTNAME supported language</link> for that matter. Opening static dialogs with Python is illustrated herewith. Exception handling and internationalization are omitted for clarity.</paragraph>
+ <h2 id="N0338">My Macros or %PRODUCTNAME Macros dialogs</h2>
+ <paragraph role="paragraph" id="N0339">The examples below open <literal>Access2Base Trace</literal> console or the imported <literal>TutorialsDialog</literal> dialog with <menuitem>Tools – Macros – Run Macro...</menuitem> menu:</paragraph>
+ <pycode>
+ <paragraph role="pycode" id="N0340" localize="false"># -*- coding: utf-8 -*-</paragraph>
+ <paragraph role="pycode" id="N0341" localize="false">from __future__ import unicode_literals</paragraph>
+ <paragraph role="pycode" id="N0342" localize="false"> </paragraph>
+ <paragraph role="pycode" id="N0343" localize="false">def consoleDlg():</paragraph>
+ <paragraph role="pycode" id="N0344" localize="false"> ctx =XSCRIPTCONTEXT.getComponentContext()</paragraph>
+ <paragraph role="pycode" id="N0345" localize="false"> smgr = ctx.getServiceManager()</paragraph>
+ <paragraph role="pycode" id="N0346" localize="false"> dp = smgr.createInstanceWithContext(&quot;com.sun.star.awt.DialogProvider&quot;, ctx)</paragraph>
+ <paragraph role="pycode" id="N0348" localize="false"> dlg = dp.createDialog( &quot;vnd.sun.star.script:Access2Base.dlgTrace?location=application&quot;)</paragraph>
+ <paragraph role="pycode" id="N0350" localize="false"> dlg.execute()</paragraph>
+ <paragraph role="pycode" id="N0351" localize="false"> dlg.dispose()</paragraph>
+ <paragraph role="pycode" id="N0352" localize="false"> </paragraph>
+ <paragraph role="pycode" id="N0353" localize="false">def tutorDialog():</paragraph>
+ <paragraph role="pycode" id="N0354" localize="false"> ctx =XSCRIPTCONTEXT.getComponentContext()</paragraph>
+ <paragraph role="pycode" id="N0355" localize="false"> smgr = ctx.getServiceManager()</paragraph>
+ <paragraph role="pycode" id="N0356" localize="false"> dp = smgr.createInstanceWithContext(&quot;com.sun.star.awt.DialogProvider&quot;, ctx)</paragraph>
+ <paragraph role="pycode" id="N0358" localize="false"> dlg = dp.createDialog(&quot;vnd.sun.star.script:Standard.TutorialsDialog?location=application&quot;)</paragraph>
+ <paragraph role="pycode" id="N0360" localize="false"> dlg.execute()</paragraph>
+ <paragraph role="pycode" id="N0361" localize="false"> dlg.dispose()</paragraph>
+ <paragraph role="pycode" id="N0362" localize="false"> </paragraph>
+ <paragraph role="pycode" id="N0363" localize="false">g_exportedScripts = (consoleDlg, tutorDialog)</paragraph>
+ </pycode>
+ <h2 id="N0364">Document embedded dialogs</h2>
+ <paragraph role="paragraph" id="N0365">The example below opens a newly edited <literal>Dialog1</literal> dialog from a document with <menuitem>Tools – Macros – Run Macro...</menuitem> menu:</paragraph>
+ <pycode>
+ <paragraph role="pycode" id="N0366" localize="false"># -*- coding: utf-8 -*-</paragraph>
+ <paragraph role="pycode" id="N0367" localize="false">from __future__ import unicode_literals</paragraph>
+ <paragraph role="pycode" id="N0368" localize="false"> </paragraph>
+ <paragraph role="pycode" id="N0369" localize="false">def docDialog():</paragraph>
+ <paragraph role="pycode" id="N0370"> &quot;&quot;&quot; Display a doc-based dialog &quot;&quot;&quot;</paragraph>
+ <paragraph role="pycode" id="N0371" localize="false"> model = XSCRIPTCONTEXT.getDocument()</paragraph>
+ <paragraph role="pycode" id="N0372" localize="false"> smgr = XSCRIPTCONTEXT.getComponentContext().ServiceManager</paragraph>
+ <paragraph role="pycode" id="N0373" localize="false"> dp = smgr.createInstanceWithArguments( &quot;com.sun.star.awt.DialogProvider&quot;, (model,))</paragraph>
+ <paragraph role="pycode" id="N0375" localize="false"> dlg = dp.createDialog( &quot;vnd.sun.star.script:Standard.Dialog1?location=document&quot;)</paragraph>
+ <paragraph role="pycode" id="N0377" localize="false"> dlg.execute()</paragraph>
+ <paragraph role="pycode" id="N0378" localize="false"> dlg.dispose()</paragraph>
+ <paragraph role="pycode" id="N0379" localize="false"> </paragraph>
+ <paragraph role="pycode" id="N0380" localize="false">g_exportedScripts = (docDialog,)</paragraph>
+ </pycode>
+ <paragraph role="paragraph" id="N0381">Refer to <literal>msgbox.py</literal> in <literal>{installation}/program/</literal> directory for Python dynamic dialog examples.</paragraph>
+ <section id="relatedtopics" >
+ <embed href="text/sbasic/guide/show_dialog.xhp#show_dialog"/>
+ <embed href="text/sbasic/python/python_examples.xhp#pythonexamples2"/>
+ <embed href="text/sbasic/python/main0000.xhp#pythonscriptshelp"/>
+ </section>
+</body>
+</helpdocument>