Avaiga / taipy

Turns Data and AI algorithms into production-ready web applications in no time.
https://www.taipy.io
Apache License 2.0
10.94k stars 775 forks source link

[🐛 BUG] f-string syntax not working in lambda expression #1504

Closed FlorianJacta closed 1 month ago

FlorianJacta commented 1 month ago

What went wrong? 🤔

Using {} in a lambda expression will result in the visual element not showing up.

Expected Behavior

We should find a way to make it work. If it is impossible, we should have some kind of warning and documentation.

Steps to Reproduce Issue

from taipy.gui import Gui 
import taipy.gui.builder as tgb

value = 10

with tgb.Page() as page:
    # Not working
    tgb.text(value=lambda value: f"1: Value {value}")
    # Not working
    tgb.text(value=lambda value: "2: Value {value}")
    # Works
    tgb.text(value=lambda value: "3: Value " + str(value))
    # Works
    tgb.text("4: Value {value}")

Gui(page=page).run(title="Frontend Demo")

image

Browsers

Chrome

OS

Windows

Version of Taipy

Develop - 7/11/24

Additional Context

No response

Acceptance Criteria

Code of Conduct

FredLL-Avaiga commented 1 month ago

tgb.text(value=lambda value: "2: Value {value}") will never work

FredLL-Avaiga commented 1 month ago
tgb.text(value=lambda value: "2: Value {value}")

But it should return a value ! ie 2: Value {value}

FlorianJacta commented 1 month ago

Yes, it was just breaking the code. I don't want it to be interactive.