[Libreoffice-commits] help.git: AllLangHelp_sbasic.mk source/text

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Feb 21 15:22:31 UTC 2019


 AllLangHelp_sbasic.mk                         |    1 
 source/text/sbasic/python/python_dialogs.xhp  |   76 ++++++++++++++++++++++++++
 source/text/sbasic/python/python_examples.xhp |    2 
 3 files changed, 78 insertions(+), 1 deletion(-)

New commits:
commit 5489ccad66f7bb892c09c68baa9d38b351c01b59
Author:     Alain Romedenne <OpenOfficiant at sfr.fr>
AuthorDate: Wed Feb 20 13:22:05 2019 -0300
Commit:     Olivier Hallot <olivier.hallot at libreoffice.org>
CommitDate: Thu Feb 21 16:22:07 2019 +0100

    Python: Help pages on opening dialogs
    
    Change-Id: Ib71ad229ff908c1bb7c426f2242729d53cb01ff8
    Reviewed-on: https://gerrit.libreoffice.org/68100
    Tested-by: Jenkins
    Reviewed-by: LibreOfficiant <OpenOfficiant at sfr.fr>
    Reviewed-by: Olivier Hallot <olivier.hallot at libreoffice.org>

diff --git a/AllLangHelp_sbasic.mk b/AllLangHelp_sbasic.mk
index bc44ddbce..859e79439 100644
--- a/AllLangHelp_sbasic.mk
+++ b/AllLangHelp_sbasic.mk
@@ -369,6 +369,7 @@ $(eval $(call gb_AllLangHelp_add_helpfiles,sbasic,\
     helpcontent2/source/text/sbasic/shared/special_vba_func \
     helpcontent2/source/text/sbasic/shared/vbasupport \
     helpcontent2/source/text/sbasic/python/main0000 \
+    helpcontent2/source/text/sbasic/python/python_dialogs \
     helpcontent2/source/text/sbasic/python/python_examples \
     helpcontent2/source/text/sbasic/python/python_ide \
     helpcontent2/source/text/sbasic/python/python_import \
diff --git a/source/text/sbasic/python/python_dialogs.xhp b/source/text/sbasic/python/python_dialogs.xhp
new file mode 100644
index 000000000..2ba1ad81f
--- /dev/null
+++ b/source/text/sbasic/python/python_dialogs.xhp
@@ -0,0 +1,76 @@
+<?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">Python : Opening a Dialog</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 in 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="dialaog 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 on 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("com.sun.star.awt.DialogProvider", ctx)</paragraph>
+        <paragraph role="pycode" id="N0348" localize="false">    dlg = dp.createDialog( "vnd.sun.star.script:Access2Base.dlgTrace?location=application")</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("com.sun.star.awt.DialogProvider", ctx)</paragraph>
+        <paragraph role="pycode" id="N0358" localize="false">    dlg = dp.createDialog("vnd.sun.star.script:Standard.TutorialsDialog?location=application")</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">    """ Display a doc-based dialog """</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( "com.sun.star.awt.DialogProvider", (model,))</paragraph>
+        <paragraph role="pycode" id="N0375" localize="false">    dlg = dp.createDialog( "vnd.sun.star.script:Standard.Dialog1?location=document")</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>
+    <section id="relatedtopics" >
+        <paragraph role="paragraph" id="N0381">
+            Refer to <literal>msgbox.py</literal> in <literal><$installation>/program/</literal> directory for an example of Python dynamic dialogs.
+        </paragraph>
+        <embed href="text/sbasic/python/python_examples.xhp#pythonexamples2"/>
+        <embed href="text/sbasic/python/main0000.xhp#pythonscriptshelp"/>
+    </section>
+</body>
+</helpdocument>
diff --git a/source/text/sbasic/python/python_examples.xhp b/source/text/sbasic/python/python_examples.xhp
index 3dd1c5564..779bfddef 100644
--- a/source/text/sbasic/python/python_examples.xhp
+++ b/source/text/sbasic/python/python_examples.xhp
@@ -28,13 +28,13 @@
     <!--
     <embed href="text/sbasic/python/python_2_basic.xhp#python2basic"/>
     <embed href="text/sbasic/python/python_from_basic.xhp#pythonfrombasic"/>
-    <embed href="text/sbasic/python/python_dialog.xhp#pythondialog"/>
     <embed href="text/sbasic/python/python_listener.xhp#pythonlistener"/>
     -->
     <embed href="text/sbasic/python/python_session.xhp#pythonsession"/>
     <embed href="text/sbasic/python/python_platform.xhp#pythonplatform"/>
     <embed href="text/sbasic/python/python_import.xhp#pythonimporth1"/>
     <embed href="text/sbasic/python/python_screen.xhp#ioscreen"/>
+    <embed href="text/sbasic/python/python_dialogs.xhp#pythondialog"/>
     <section id="relatedtopics">
         <embed href="text/sbasic/python/main0000.xhp#pythonscriptshelp"/>
     </section>


More information about the Libreoffice-commits mailing list