Sfoglia il codice sorgente

Add examples for the text control. (#1578)

Fabien Lelaquais 9 mesi fa
parent
commit
b8b9e12ba7

+ 27 - 0
doc/gui/examples/controls/text-format.py

@@ -0,0 +1,27 @@
+# Copyright 2021-2024 Avaiga Private Limited
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations under the License.
+# -----------------------------------------------------------------------------------------
+# To execute this script, make sure that the taipy-gui package is installed in your
+# Python environment and run:
+#     python <script>
+# -----------------------------------------------------------------------------------------
+from taipy.gui import Gui
+
+pi = 3.14159265358979
+
+page = """
+# Text - Formatting
+<|toggle|theme|>
+
+π≈<|{pi}|text|format=%.3f|>
+"""
+
+Gui(page).run()

+ 35 - 0
doc/gui/examples/controls/text-md.py

@@ -0,0 +1,35 @@
+# Copyright 2021-2024 Avaiga Private Limited
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations under the License.
+# -----------------------------------------------------------------------------------------
+# To execute this script, make sure that the taipy-gui package is installed in your
+# Python environment and run:
+#     python <script>
+# -----------------------------------------------------------------------------------------
+from taipy.gui import Gui
+
+markdown = """
+# Generated by *Taipy*
+
+You can insert *Markdown* code in a `text` control to
+add style to the text.
+
+If a line ends with two white spaces, such as here  
+then you can create line skips.
+"""
+
+page = """
+# Text - Markdown
+<|toggle|theme|>
+
+<|{markdown}|text|mode=markdown|>
+"""
+
+Gui(page).run()

+ 33 - 0
doc/gui/examples/controls/text-pre.py

@@ -0,0 +1,33 @@
+# Copyright 2021-2024 Avaiga Private Limited
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations under the License.
+# -----------------------------------------------------------------------------------------
+# To execute this script, make sure that the taipy-gui package is installed in your
+# Python environment and run:
+#     python <script>
+# -----------------------------------------------------------------------------------------
+from taipy.gui import Gui
+
+code = """
+def say_hello(name: str):
+    print(f"Hello, {name}!")
+
+if __name__ == "__main__":
+    say_hello("Taipy")
+"""
+
+page = """
+# Text - pre
+<|toggle|theme|>
+
+<|{code}|text|mode=pre|>
+"""
+
+Gui(page).run()

+ 27 - 0
doc/gui/examples/controls/text-simple.py

@@ -0,0 +1,27 @@
+# Copyright 2021-2024 Avaiga Private Limited
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations under the License.
+# -----------------------------------------------------------------------------------------
+# To execute this script, make sure that the taipy-gui package is installed in your
+# Python environment and run:
+#     python <script>
+# -----------------------------------------------------------------------------------------
+from taipy.gui import Gui
+
+name = "Taipy"
+
+page = """
+# Text - simple
+<|toggle|theme|>
+
+<|Hello {name}!|>
+"""
+
+Gui(page).run()

+ 6 - 6
taipy/gui/viselements.json

@@ -627,7 +627,7 @@
                     {
                         "name": "decimator",
                         "type": "indexed(taipy.gui.data.Decimator)",
-                        "doc": "A decimator instance for the indicated trace that will reduce the size of the data being sent back and forth.<br>If defined as indexed, it will impact only the indicated trace; if not, it will apply only the first trace."
+                        "doc": "A decimator instance for the indicated trace that reduces the volume of the data being sent back and forth.<br>If defined as <i>indexed</i>, it impacts only the indicated trace; if not, it applies to the first trace only."
                     },
                     {
                         "name": "rebuild",
@@ -1224,7 +1224,7 @@
                     {
                         "name": "color_map",
                         "type": "dict",
-                        "doc": "TODO The color_map is used to display different colors for different ranges of the metric. The color_map's keys represent the starting point of each range, which is a number, while the values represent the corresponding color for that range. If the value associated with a key is set to None, it implies that the corresponding range will not be assigned any color."
+                        "doc": "TODO The color_map is used to display different colors for different ranges of the metric. The color_map's keys represent the starting point of each range, which is a number, while the values represent the corresponding color for that range. If the value associated with a key is set to None, it implies that the corresponding range is not assigned any color."
                     },
                     {
                         "name": "width",
@@ -1615,7 +1615,7 @@
                         "name": "class_name",
                         "default_property": true,
                         "type": "dynamic(str)",
-                        "doc": "A list of CSS class names, separated by white spaces, that will be associated with the generated HTML Element.<br/>These class names are added to the default <code>taipy-part</code>."
+                        "doc": "A list of CSS class names, separated by white spaces, that are associated with the generated HTML Element.<br/>These class names are added to the default <code>taipy-part</code> class name."
                     },
                     {
                         "name": "page",
@@ -1698,7 +1698,7 @@
                         "name": "close_label",
                         "type": "str",
                         "default_value": "\"Close\"",
-                        "doc": "The tooltip of the top-right close icon button. In the <tt>on_action</tt> callback, args will hold -1."
+                        "doc": "The tooltip of the top-right close icon button. In the <tt>on_action</tt> callback, <i>args</i> will be set to -1."
                     },
                     {
                         "name": "labels",
@@ -1965,7 +1965,7 @@
                     {
                         "name": "id",
                         "type": "str",
-                        "doc": "The identifier that will be assigned to the rendered HTML component."
+                        "doc": "The identifier that is assigned to the rendered HTML component."
                     },
                     {
                         "name": "properties",
@@ -1975,7 +1975,7 @@
                     {
                         "name": "class_name",
                         "type": "dynamic(str)",
-                        "doc": "The list of CSS class names that will be associated with the generated HTML Element.<br/>These class names will be added to the default <code>taipy-&lt;element_type&gt;</code>."
+                        "doc": "The list of CSS class names that are associated with the generated HTML Element.<br/>These class names are added to the default <code>taipy-&lt;element_type&gt;</code> class name."
                     },
                     {
                         "name": "hover_text",