Skip to content

Commit

Permalink
Scenario_selector select scenario after on_creation (#1650)
Browse files Browse the repository at this point in the history
resolves #1619

Co-authored-by: Fred Lefévère-Laoide <[email protected]>
  • Loading branch information
FredLL-Avaiga and Fred Lefévère-Laoide authored Aug 8, 2024
1 parent fae0413 commit 2555495
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions taipy/gui_core/_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ def crud_scenario(self, state: State, id: str, payload: t.Dict[str, str]): # no
data = args[start_idx + 2]
with_dialog = True if len(args) < start_idx + 4 else bool(args[start_idx + 3])
scenario = None
user_scenario = None

name = data.get(_GuiCoreContext.__PROP_ENTITY_NAME)
if update:
Expand Down Expand Up @@ -468,7 +469,8 @@ def crud_scenario(self, state: State, id: str, payload: t.Dict[str, str]): # no
)
if isinstance(res, Scenario):
# everything's fine
scenario_id = res.id
user_scenario = res
scenario_id = user_scenario.id
state.assign(error_var, "")
return
if res:
Expand Down Expand Up @@ -502,10 +504,10 @@ def crud_scenario(self, state: State, id: str, payload: t.Dict[str, str]): # no
state.assign(error_var, f"Error creating Scenario. {e}")
finally:
self.scenario_refresh(scenario_id)
if scenario and (sel_scenario_var := args[1] if isinstance(args[1], str) else None):
if (scenario or user_scenario) and (sel_scenario_var := args[1] if isinstance(args[1], str) else None):
try:
var_name, _ = gui._get_real_var_name(sel_scenario_var)
state.assign(var_name, scenario)
state.assign(var_name, scenario or user_scenario)
except Exception as e: # pragma: no cover
_warn("Can't find value variable name in context", e)
if scenario:
Expand Down

0 comments on commit 2555495

Please sign in to comment.