Avaiga / taipy-gui

Graphical User Interface generator for Taipy
Apache License 2.0
60 stars 20 forks source link

BUG-Taipy 3.0.0 has "action" swapped with "payload" #1009

Closed gbritoda closed 1 year ago

gbritoda commented 1 year ago

Description On TaiPy 2.4.0, whenever a table called on_action, the payload variable contained the index, col etc. And this is what is expected according to the documentation.

payload (dict): the details on this callback's invocation.
This dictionary has the following keys:

    index (int): the row index.

However, in TaiPy 3.0.0 this seems to have gone to the action field and payload is None

How to reproduce Click on any row of the table and on_table_action will be called.

from taipy.gui import Gui

# x: [1..5]
x_range = range(1, 6)
data = {
    "X": x_range,
    "Y": [x*x for x in x_range]
}

column_orders = [("X;Y", "Squared"), ("Y;X", "Square root")]
columns = column_orders[0]

page = """
<|{data}|table|columns={columns[0]}|show_all|on_action=on_table_action|>

<|{columns}|toggle|lov={column_orders}|>
"""

def on_table_action(state, var_name, action, payload):
    print(f"on_table_action: {locals()}")

Gui(page=page).run()

Then check the printout, it is: on_table_action: {'state': <taipy.gui.state.State object at 0x7f60d8311750>, 'var_name': 'data', 'action': {'action': 'on_table_action', 'index': 2, 'col': 'X', 'args': []}, 'payload': None}

Expected behavior Printout should be on_table_action: {'state': <taipy.gui.state.State object at 0x7f0a2f65f7c0>, 'var_name': 'data', 'action': 'on_table_action', 'payload': {'action': 'on_table_action', 'index': 3, 'args': []}} , and in fact, it is what I get when using python 2.4.0

Runtime environment TaiPy 3.0.0

FlorianJacta commented 1 year ago

In Taipy 3.0, the action parameter of the on_action callback was removed for every control. This is a breaking change that you can find in Release Notes. The signature of all on_action() callback functions are now unified to the following:

Did you have any use of it in Taipy 2.4?

gbritoda commented 1 year ago

Oh right!

No, I did not use it, and even if I did I can still use it on the payload dict. I also just realised that the documentation I was looking at was not for the 3.0.0 release! Sorry about that, will close the issue!