Repository: Avaiga/taipy
Pull request: Access all elements from the root of Builder API (#418)
Resolve #418

```
import taipy.gui.builder as tgb
from taipy.gui import Gui

with tgb.Page() as page:
    tgb.scenario(None)


Gui(page=page).run()

```

Problem statement:
Access Gui-Core viz elements from the root of taipy gui builder
All Gui-Core visual elements should be accessible through the Taipy Gui Builder API.

This should work:
```python
from taipy.gui import Gui 
import taipy.gui.builder as tgb


with tgb.Page() as page:
    tgb.scenario(None)


Gui(page=page).run()
```

Hints from issue discussion:
Is it really solved? This is still not working on my side

![image](https://github.com/Avaiga/taipy/assets/98709993/3725adb8-9455-48c6-b59b-4d2bc6dc9b21)

Any update on this?
Did you try `tgb.gui_core.scenario`
```
C:\Users\jacta\.conda\envs\enterprise_3_1\lib\site-packages\taipy\gui\gui.py:774: TaipyGuiWarning: on_change(): callback function raised an exception:
module 'taipy.gui.builder' has no attribute 'gui_core'
```

Not working here
right now, on 3.1, you can use this syntax to access the gui_core
```
import taipy.gui.builder as tgb
from taipy.gui import Gui

with tgb.Page() as page:
    tgb.taipy_gui_core.scenario(None)


Gui(page=page).run()
```
I will allow the access of all element from the root of tgb

Commit message: Access all elements from the root of Builder API

Patch to review:
diff --git a/taipy/gui/builder/_api_generator.py b/taipy/gui/builder/_api_generator.py
index 9a20593cf2..1a002d2da3 100644
--- a/taipy/gui/builder/_api_generator.py
+++ b/taipy/gui/builder/_api_generator.py
@@ -83,6 +83,13 @@ def add_library(self, library: "ElementLibrary"):
                     element_name, f"{library_name}.{element_name}", element.default_attribute
                 ),
             )
+            # Allow element to be accessed from the root module
+            if hasattr(self.__module, element_name):
+                _TaipyLogger()._get_logger().info(
+                    f"Can't add element `{element_name}` of library `{library_name}` to the root of Builder API as it has already existed."  # noqa: E501
+                )
+                continue
+            setattr(self.__module, element_name, getattr(library_module, element_name))
 
     @staticmethod
     def create_block_api(


Code review comments:
diff_hunk: @@ -83,6 +83,13 @@ def add_library(self, library: "ElementLibrary"):
                     element_name, f"{library_name}.{element_name}", element.default_attribute
                 ),
             )
+            # Allow element to be accessed from the root module
+            if hasattr(self.__module, element_name):
+                _TaipyLogger()._get_logger().info(
+                    f"Can't add element `{element_name}` of library `{library_name}` to the root of Builder API as it has already existed."  # noqa: E501
path: taipy/gui/builder/_api_generator.py
text: @user1:
Another element with the same name already exists

@author:
just thought of it also. Thanks for the suggestion