-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #773 from Avaiga/doc/GS-with-tgb
Add TGB in GS
- Loading branch information
Showing
3 changed files
with
147 additions
and
37 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import taipy as tp | ||
from taipy import Config, Core, Gui | ||
import taipy.gui.builder as tgb | ||
|
||
|
||
################################################################ | ||
# Configure application # | ||
################################################################ | ||
def build_message(name): | ||
return f"Hello {name}!" | ||
|
||
|
||
# A first data node configuration to model an input name. | ||
input_name_data_node_cfg = Config.configure_data_node(id="input_name") | ||
# A second data node configuration to model the message to display. | ||
message_data_node_cfg = Config.configure_data_node(id="message") | ||
# A task configuration to model the build_message function. | ||
build_msg_task_cfg = Config.configure_task("build_msg", build_message, input_name_data_node_cfg, message_data_node_cfg) | ||
# The scenario configuration represents the whole execution graph. | ||
scenario_cfg = Config.configure_scenario("scenario", task_configs=[build_msg_task_cfg]) | ||
|
||
################################################################ | ||
# Design graphical interface # | ||
################################################################ | ||
|
||
input_name = "Taipy" | ||
message = None | ||
|
||
|
||
def submit_scenario(state): | ||
state.scenario.input_name.write(state.input_name) | ||
state.scenario.submit() | ||
state.message = scenario.message.read() | ||
|
||
with tgb.Page() as page: | ||
tgb.text("Name:") | ||
tgb.input("{input_name}") | ||
tgb.button("Submit", on_action=submit_scenario) | ||
|
||
tgb.text("Message {message}") | ||
|
||
if __name__ == "__main__": | ||
################################################################ | ||
# Instantiate and run Core service # | ||
################################################################ | ||
Core().run() | ||
|
||
################################################################ | ||
# Manage scenarios and data nodes # | ||
################################################################ | ||
scenario = tp.create_scenario(scenario_cfg) | ||
|
||
################################################################ | ||
# Instantiate and run Gui service # | ||
################################################################ | ||
|
||
Gui(page).run() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters