diff --git a/doc/gui/examples/controls/chat_calculator.py b/doc/gui/examples/controls/chat_calculator.py index b2ee454448..442b47530a 100644 --- a/doc/gui/examples/controls/chat_calculator.py +++ b/doc/gui/examples/controls/chat_calculator.py @@ -16,20 +16,19 @@ # Human-computer dialog UI based on the chat control. # ----------------------------------------------------------------------------------------- from math import cos, pi, sin, sqrt, tan # noqa: F401 -from typing import Optional from taipy.gui import Gui # The user interacts with the Python interpreter users = ["human", "Result"] -messages: list[tuple[str, str, str, Optional[str]]] = [] +messages: list[tuple[str, str, str]] = [] def evaluate(state, var_name: str, payload: dict): # Retrieve the callback parameters - (_, _, expression, sender_id, image_url) = payload.get("args", []) + (_, _, expression, sender_id, _) = payload.get("args", []) # Add the input content as a sent message - messages.append((f"{len(messages)}", expression, sender_id, image_url)) + messages.append((f"{len(messages)}", expression, sender_id)) # Default message used if evaluation fails result = "Invalid expression" try: @@ -38,12 +37,12 @@ def evaluate(state, var_name: str, payload: dict): except Exception: pass # Add the result as an incoming message - messages.append((f"{len(messages)}", result, users[1], None)) + messages.append((f"{len(messages)}", result, users[1])) state.messages = messages page = """ -<|{messages}|chat|users={users}|sender_id={users[0]}|on_action=evaluate|> +<|{messages}|chat|users={users}|sender_id={users[0]}|on_action=evaluate|don't allow_send_images|> """ Gui(page).run(title="Chat - Calculator") diff --git a/doc/gui/examples/controls/chat_discuss.py b/doc/gui/examples/controls/chat_discuss.py index 4d46f66f26..cd9775057c 100644 --- a/doc/gui/examples/controls/chat_discuss.py +++ b/doc/gui/examples/controls/chat_discuss.py @@ -25,7 +25,7 @@ from taipy.gui.gui_actions import navigate, notify username = "" -users: list[Union[str, Icon]] = [] +users: list[tuple[str, Union[str, Icon]]] = [] messages: list[tuple[str, str, str, Optional[str]]] = [] Gui.add_shared_variables("messages", "users") @@ -82,4 +82,6 @@ def send(state, _: str, payload: dict): """ pages = {"register": register_page, "discuss": discuss_page} -gui = Gui(pages=pages).run(title="Chat - Discuss") + +if __name__ == "__main__": + gui = Gui(pages=pages).run(title="Chat - Discuss") diff --git a/doc/gui/examples/controls/chat_images.py b/doc/gui/examples/controls/chat_images.py new file mode 100644 index 0000000000..2e7667c1de --- /dev/null +++ b/doc/gui/examples/controls/chat_images.py @@ -0,0 +1,47 @@ +# 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