AllLangHelp_sbasic.mk                         |    1 
 source/text/sbasic/python/python_examples.xhp |    5 -
 source/text/sbasic/python/python_screen.xhp   |  104 ++++++++++++++++++++++++++
 source/text/sbasic/shared/03010000.xhp        |    4 -
 4 files changed, 109 insertions(+), 5 deletions(-)

New commits:
commit f601cf7f5da7ff3986cde52b34962c56b00fd5f6
Author:     Alain Romedenne <pyoffice.romede...@sfr.fr>
AuthorDate: Wed Jan 16 11:20:08 2019 -0200
Commit:     Olivier Hallot <olivier.hal...@libreoffice.org>
CommitDate: Fri Jan 18 11:06:27 2019 +0100

    Python Help page for screen IO
    
    Change-Id: I0a1fc11a23c6f48eb058d42541e1f22c57ddb26d
    Reviewed-on: https://gerrit.libreoffice.org/66442
    Tested-by: Jenkins
    Reviewed-by: Olivier Hallot <olivier.hal...@libreoffice.org>

diff --git a/AllLangHelp_sbasic.mk b/AllLangHelp_sbasic.mk
index b76014f32..cc08cf424 100644
--- a/AllLangHelp_sbasic.mk
+++ b/AllLangHelp_sbasic.mk
@@ -370,6 +370,7 @@ $(eval $(call gb_AllLangHelp_add_helpfiles,sbasic,\
     helpcontent2/source/text/sbasic/python/python_ide \
     helpcontent2/source/text/sbasic/python/python_locations \
     helpcontent2/source/text/sbasic/python/python_programming \
+    helpcontent2/source/text/sbasic/python/python_screen \
     helpcontent2/source/text/sbasic/python/python_shell \
 ))
 
diff --git a/source/text/sbasic/python/python_examples.xhp 
b/source/text/sbasic/python/python_examples.xhp
index 86e2aac53..40c00f8e3 100644
--- a/source/text/sbasic/python/python_examples.xhp
+++ b/source/text/sbasic/python/python_examples.xhp
@@ -21,6 +21,7 @@
             <bookmark_value>Python;shell</bookmark_value>
             <bookmark_value>Python;platform</bookmark_value>
             <bookmark_value>Python;session</bookmark_value>
+            <bookmark_value>Python;screen input/output</bookmark_value>
         </bookmark>
         <h1 id="hd_id201901031407"><variable id="pythonexamples2"><link 
href="text/sbasic/python/python_examples.xhp" name="python examples">Python 
programming examples</link></variable></h1>
     </section>
@@ -32,8 +33,8 @@
     <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#pythonimport"/>
-    <embed href="text/sbasic/python/python_screen.xhp#pythonscreen"/>
-    <embed href="text/sbasic/python/python_shell.xhp#pythonshell"/>
     -->
+    <embed href="text/sbasic/python/python_screen.xhp#ioscreen"/>
+    <!--<embed href="text/sbasic/python/python_shell.xhp#pythonshell"/>-->
 </body>
 </helpdocument>
diff --git a/source/text/sbasic/python/python_screen.xhp 
b/source/text/sbasic/python/python_screen.xhp
new file mode 100644
index 000000000..a3d8077ee
--- /dev/null
+++ b/source/text/sbasic/python/python_screen.xhp
@@ -0,0 +1,104 @@
+<?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_screen">
+            <title id="tit">Python : Screen Input/Output</title>
+            <filename>/text/sbasic/python/python_screen.xhp</filename>
+        </topic>
+    </meta>
+    <body>
+    <bookmark branch="index" xml-lang="en-US" id="N0433">
+        <bookmark_value>Python;InputBox</bookmark_value>
+        <bookmark_value>Python;MsgBox</bookmark_value>
+        <bookmark_value>Python;Print</bookmark_value>
+    </bookmark>
+    <h1 id="N0434"><variable id="ioscreen"><link 
href="text/sbasic/python/python_screen.xhp" name="IO to screen">Input/Output to 
Screen</link></variable></h1>
+    <paragraph role="paragraph" id="N0435">Python standard output file is not 
available when running Python macros from <menuitem>Tools – Macros - Run 
Macro</menuitem>... menu. Presenting the output of a module requires the Python 
interactive console. Features such as <literal>input()</literal>, 
<literal>print()</literal>, <literal>repr()</literal> and 
<literal>str()</literal> are available from the Python shell.</paragraph>
+    <paragraph role="tip" id="N0436">The <link 
href="https://extensions.libreoffice.org/extensions/apso-alternative-script-organizer-for-python";
 name ="apso">Alternative Python Script Organizer</link> (APSO) extension 
offers a msgbox() function out of its <literal>apso_utils</literal> 
module.</paragraph>
+    <paragraph role="paragraph" id="N0437">%PRODUCTNAME Basic proposes 
<literal>InputBox()</literal>, <literal>Msgbox()</literal> and 
<literal>Print()</literal> screen I/O functions. Python alternatives exist 
relying either on %PRODUCTNAME API Abstract Windowing Toolkit, either on Python 
to Basic function calls. The latter proposes a syntax that is intentionally 
close to that of Basic, and uses a Python module next to a Basic module. The 
API Scripting Framework is used to perform Basic, Beanshell, JavaScript and 
Python inter-languages function calls.</paragraph>
+    <h2 id="N0438">Python syntax:</h2>
+    <paragraph role="code" id="N0439" localize="false">MsgBox(txt, buttons=0, 
title=None)<br/></paragraph>
+    <paragraph role="code" id="N0440" localize="false">InputBox(txt, 
title=None, default=None)<br/></paragraph>
+    <paragraph role="code" id="N0441" localize="false">Print(txt)</paragraph>
+    <h2 id="N0442">Examples:</h2>
+    <paragraph role="paragraph" localize="false" 
id="N0443"><literal>&gt;&gt;&gt; import screen_io as ui</literal></paragraph>
+    <paragraph role="paragraph" localize="false" 
id="N0445"><literal>&gt;&gt;&gt; reply = ui.InputBox(&apos;Please enter a 
phrase&apos;, title=&apos;Dear user&apos;, 
default=&quot;here..&quot;)</literal></paragraph>
+    <paragraph role="paragraph" localize="false" 
id="N0446"><literal>&gt;&gt;&gt; rc = ui.MsgBox(reply, title=&quot;Confirmation 
of phrase&quot;)</literal></paragraph>
+    <paragraph role="paragraph" localize="false" 
id="N0447"><literal>&gt;&gt;&gt; age = ui.InputBox(&apos;How old are 
you?&apos;, title=&quot;Hi&quot;)</literal></paragraph>
+    <paragraph role="paragraph" localize="false" 
id="N0448"><literal>&gt;&gt;&gt; ui.Print(age)</literal></paragraph>
+    <h2 id="N0449">Installation:</h2>
+    <list type="unordered">
+        <listitem>
+            <paragraph role="listitem" id="N0450">Copy 
<literal>screen_io</literal> Python module in <link 
href="text/sbasic/python/python_locations.xhp">My macros</link> within 
&lt;UserProfile&gt;/Scripts/python/pythonpath,</paragraph>
+        </listitem>
+        <listitem>
+            <paragraph role="listitem" id="N0451">Copy 
<literal>uiScripts</literal> Basic module in <link 
href="text/sbasic/python/python_locations.xhp">My macros</link> Standard Basic 
library,</paragraph>
+        </listitem>
+        <listitem>
+            <paragraph role="listitem" id="N0452">Restart 
%PRODUCTNAME.</paragraph>
+        </listitem>
+    </list>
+    <h3 id="N0453"><literal>screen_io</literal> Python module</h3>
+    <pycode>
+        <paragraph role="pycode" localize="false" id="N0454"># -*- coding: 
utf-8 -*-</paragraph>
+        <paragraph role="pycode" localize="false" id="N0455">from __future__ 
import unicode_literals</paragraph>
+        <paragraph role="pycode" localize="false" id="N0456"></paragraph>
+        <paragraph role="pycode" localize="false" id="N0466">def 
MsgBox(prompt: str, buttons=0, title=&apos;LibreOffice&apos;) -&gt; 
int:</paragraph>
+        <paragraph role="pycode" id="N0467">    &quot;&quot;&quot; Displays a 
dialogue box containing a message and returns a 
value.&quot;&quot;&quot;</paragraph>
+        <paragraph role="pycode" localize="false" id="N0468">    xScript = 
_getScript(&quot;_MsgBox&quot;)</paragraph>
+        <paragraph role="pycode" localize="false" id="N0469">    res = 
xScript.invoke((prompt,buttons,title), (), ())</paragraph>
+        <paragraph role="pycode" localize="false" id="N0470">    return 
res[0]</paragraph>
+        <paragraph role="pycode" localize="false" id="N0471"></paragraph>
+        <paragraph role="pycode" localize="false" id="N0472">def 
InputBox(prompt: str, title=&apos;LibreOffice&apos;, defaultValue=&apos;&apos;) 
-&gt; str:</paragraph>
+        <paragraph role="pycode" id="N0473">    &quot;&quot;&quot; Displays a 
prompt in a dialogue box at which the user can enter 
text.&quot;&quot;&quot;</paragraph>
+        <paragraph role="pycode" localize="false" id="N0474">    xScript = 
_getScript(&quot;_InputBox&quot;)</paragraph>
+        <paragraph role="pycode" localize="false" id="N0475">    res = 
xScript.invoke((prompt,title,defaultValue), (), ())</paragraph>
+        <paragraph role="pycode" localize="false" id="N0476">    return 
res[0]</paragraph>
+        <paragraph role="pycode" localize="false" id="N0477"></paragraph>
+        <paragraph role="pycode" localize="false" id="N0478">def 
Print(message: str):</paragraph>
+        <paragraph role="pycode" id="N0479">    &quot;&quot;&quot;Outputs the 
specified strings or numeric expressions in a dialogue 
box.&quot;&quot;&quot;</paragraph>
+        <paragraph role="pycode" localize="false" id="N0480">    xScript = 
_getScript(&quot;_Print&quot;)</paragraph>
+        <paragraph role="pycode" localize="false" id="N0481">    
xScript.invoke((message,), (), ())</paragraph>
+        <paragraph role="pycode" localize="false" id="N0482"></paragraph>
+        <paragraph role="pycode" localize="false" id="N0483">import 
uno</paragraph>
+        <paragraph role="pycode" localize="false" id="N0484">from 
com.sun.star.script.provider import XScript</paragraph>
+        <paragraph role="pycode" localize="false" id="N0485">def 
_getScript(script: str, library=&apos;Standard&apos;, 
module=&apos;uiScripts&apos;) -&gt; XScript:</paragraph>
+        <paragraph role="pycode" localize="false" id="N0486">    sm = 
uno.getComponentContext().ServiceManager</paragraph>
+        <paragraph role="pycode" localize="false" id="N0487">    mspf = 
sm.createInstanceWithContext(&quot;com.sun.star.script.provider.MasterScriptProviderFactory&quot;,
 uno.getComponentContext())</paragraph>
+        <paragraph role="pycode" localize="false" id="N0488">    scriptPro = 
mspf.createScriptProvider(&quot;&quot;)</paragraph>
+        <paragraph role="pycode" localize="false" id="N0489">    scriptName = 
&quot;vnd.sun.star.script:&quot;+library+&quot;.&quot;+module+&quot;.&quot;+script+&quot;?language=Basic&amp;location=application&quot;</paragraph>
+        <paragraph role="pycode" localize="false" id="N0490">    xScript = 
scriptPro.getScript(scriptName)</paragraph>
+        <paragraph role="pycode" localize="false" id="N0491">    return 
xScript</paragraph>
+    </pycode>
+    <h3 id="N0492"><literal>uiScripts</literal> Basic module</h3>
+    <bascode>
+        <paragraph role="bascode" localize="false" id="N0493">Option 
Explicit</paragraph>
+        <paragraph role="bascode" localize="false" id="N0494">Private Function 
_MsgBox( prompt As String, Optional buttons As Integer, _</paragraph>
+        <paragraph role="bascode" localize="false" id="N0495">        Optional 
title As String ) As Integer</paragraph>
+        <paragraph role="bascode" localize="false" id="N0496">    _MsgBox = 
MsgBox( prompt, buttons, title )</paragraph>
+        <paragraph role="bascode" localize="false" id="N0497">End 
Function</paragraph>
+        <paragraph role="bascode" localize="false" id="N0498">Private Function 
_InputBox( prompt As String, Optional title As String, _</paragraph>
+        <paragraph role="bascode" localize="false" id="N0499">        Optional 
default As String) As String</paragraph>
+        <paragraph role="bascode" localize="false" id="N0500">    _InputBox = 
InputBox( prompt, title, default )</paragraph>
+        <paragraph role="bascode" localize="false" id="N0501">End 
Function</paragraph>
+        <paragraph role="bascode" localize="false" id="N0502">Private Sub 
_Print( msg As String )</paragraph>
+        <paragraph role="bascode" localize="false" id="N0503">    Print 
msg</paragraph>
+        <paragraph role="bascode" localize="false" id="N0504">End 
Sub</paragraph>
+    </bascode>
+    <section id="relatedTopics">
+        <paragraph role="paragraph" id="N0505">
+            <link href="text/sbasic/python/python_2_basic.xhp">Calling Basic 
macros from Python</link>
+        </paragraph>
+        <embed href="text/sbasic/shared/03010000.xhp#BasicScreenIO"/>
+        <embed href="text/sbasic/python/python_examples.xhp#pythonexamples2"/>
+    </section>
+</body>
+</helpdocument>
diff --git a/source/text/sbasic/shared/03010000.xhp 
b/source/text/sbasic/shared/03010000.xhp
index bd9fae4df..60039275d 100644
--- a/source/text/sbasic/shared/03010000.xhp
+++ b/source/text/sbasic/shared/03010000.xhp
@@ -30,10 +30,8 @@
 </history>
 </meta>
 <body>
-  
-  
   <section id="bildschirmeinaus">
-  <paragraph id="hd_id3156280" role="heading" level="1" xml-lang="en-US"><link 
href="text/sbasic/shared/03010000.xhp" name="Screen I/O Functions">Screen I/O 
Functions</link></paragraph>
+      <h1 id="hd_id3156280"><variable id="BasicScreenIO"><link 
href="text/sbasic/shared/03010000.xhp" name="Screen I/O Functions">Screen I/O 
Functions</link></variable></h1>
   <paragraph role="paragraph" id="par_id3153770" xml-lang="en-US">This section 
describes the Runtime Functions used to call dialogs for the input and output 
of user entries.</paragraph>
   </section>
   <embed href="text/sbasic/shared/03010100.xhp#ausgabe"/>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to