Skip to content

Commit

Permalink
Rewrite Partial Builder in Python API for Scenario Management Template (
Browse files Browse the repository at this point in the history
Avaiga#1404)

* Rewrite Partial Builder in Python API for Scenario Management Template

* fix: line too long linter error

---------

Co-authored-by: trgiangdo <dtr.giang.1299@gmail.com>
  • Loading branch information
FlorianJacta and trgiangdo authored Jun 13, 2024
1 parent 0205668 commit 198a4da
Showing 1 changed file with 32 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,40 @@
# 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.

import taipy.gui.builder as tgb


# build partial content for a specific data node
def build_dn_partial(dn, dn_label):
partial_content = "<|part|render={selected_scenario}|\n\n"

# ##################################################################################################################
# PLACEHOLDER: data node specific content before automatic content #
# #
# Example: #
if dn_label == "replacement_type":
partial_content += "All missing values will be replaced by the data node value."
# Comment, remove or replace the previous lines with your own use case #
# ##################################################################################################################

# Automatic data node content
partial_content += (
"<|{selected_scenario.data_nodes['" + dn.config_id + "']}|data_node|scenario={" "selected_scenario}|>\n\n "
)

# ##################################################################################################################
# PLACEHOLDER: data node specific content after automatic content #
# #
# Example: #
if dn_label == "initial_dataset":
partial_content += (
"Select your CSV file: <|{selected_data_node.path}|file_selector|extensions=.csv|on_action"
"={lambda s: s.refresh('selected_scenario')}|>\n\n "
)
# Comment, remove or replace the previous lines with your own use case #
# ##################################################################################################################

partial_content += "|>\n\n"
with tgb.Page() as partial_content:
with tgb.part(render="{selected_scenario}"):
# ##########################################################################################################
# PLACEHOLDER: data node specific content before automatic content #
# #
# Example: #
if dn_label == "replacement_type":
tgb.text("All missing values will be replaced by the data node value.")
# Comment, remove or replace the previous lines with your own use case #
# ##########################################################################################################

# Automatic data node content
tgb.data_node("{selected_scenario.data_nodes['" + dn.config_id + "']}", scenario="{selected_scenario}")

# ##########################################################################################################
# PLACEHOLDER: data node specific content after automatic content #
# #
# Example: #
if dn_label == "initial_dataset":
tgb.text("Select your CSV file:")
tgb.file_selector(
"{selected_data_node.path}",
extensions=".csv",
on_action="{lambda s: s.refresh('selected_scenario')}",
)

# Comment, remove or replace the previous lines with your own use case #
# ##########################################################################################################

return partial_content


Expand Down

0 comments on commit 198a4da

Please sign in to comment.