Skip to content

Commit

Permalink
Merge branch 'develop' into bug/#1911-current-page-menu
Browse files Browse the repository at this point in the history
  • Loading branch information
namnguyen20999 committed Oct 14, 2024
2 parents 142c391 + 48c86e9 commit 4baa13a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Taipy is organised in two main repositories:

## Never contributed to an open source project before ?

Have a look on this [GitHub documentation](https://docs.github.com/en/get-started/quickstart/contributing-to-projects).
Have a look at this [GitHub documentation](https://docs.github.com/en/get-started/quickstart/contributing-to-projects).

## Report bugs

Expand Down Expand Up @@ -86,7 +86,7 @@ the community that you are working on it.
- Include tests.
- Code is [rebased](http://stackoverflow.com/a/7244456/1110993).
- License is present.
- pre-commit works - without mypy error.
- pre-commit works - without mypy errors.
- Taipy tests are passing.

6. The Taipy team will have a look at your Pull Request and will give feedback. If every requirement is valid, your
Expand Down Expand Up @@ -137,7 +137,7 @@ on it.
## Dependency management

Taipy comes with multiple optional packages. You can find the list directly in the product or Taipy's packages.
The back-end Pipfile does not install by default optional packages due to `pyodbc` requiring a driver's manual
The back-end Pipfile does not install optional packages by default due to `pyodbc` requiring a driver's manual
installation. This is not the behaviour for the front-end that installs all optional packages through its Pipfile.

If you are a contributor on Taipy, be careful with dependencies, do not forget to install or uninstall depending on
Expand Down
4 changes: 2 additions & 2 deletions taipy/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1506,7 +1506,7 @@ def __on_action(self, id: t.Optional[str], payload: t.Any) -> None:
return
else: # pragma: no cover
_warn(f"on_action(): '{action}' is not a valid function.")
if hasattr(self, "on_action"):
if getattr(self, "on_action", None) is not None:
self.__call_function_with_args(action_function=self.on_action, id=id, payload=payload)

def __call_function_with_args(self, **kwargs):
Expand All @@ -1520,7 +1520,7 @@ def __call_function_with_args(self, **kwargs):
args = [self._get_real_var_name(id)[0], payload]
except Exception:
args = [id, payload]
self._call_function_with_state(t.cast(t.Callable, action_function), [args])
self._call_function_with_state(t.cast(t.Callable, action_function), args)
return True
except Exception as e: # pragma: no cover
if not self._call_on_exception(action_function, e):
Expand Down
21 changes: 21 additions & 0 deletions tests/gui/gui_specific/test_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,24 @@ def test__get_valid_adapter_result(gui: Gui):
res = gui._get_valid_adapter_result(("id", "label"))
assert isinstance(res, tuple)
assert res[0] == "id"

def test_on_action_call(gui:Gui):
an_id = "my_id"

a_non_action_payload = {"a": "b"}
def on_action(state, id, payload):
assert id == an_id
assert payload is a_non_action_payload

an_action_payload = {"action": "on_an_action"}
def on_an_action(state, id, payload):
assert id == an_id
assert payload is an_action_payload

# set gui frame
gui._set_frame(inspect.currentframe())

gui.run(run_server=False)
with gui.get_flask_app().app_context():
gui._Gui__on_action(an_id, a_non_action_payload) # type: ignore[reportAttributeAccessIssue]
gui._Gui__on_action(an_id, an_action_payload) # type: ignore[reportAttributeAccessIssue]

0 comments on commit 4baa13a

Please sign in to comment.