Skip to content

Commit

Permalink
inline tgb controls (#1725) (#1769)
Browse files Browse the repository at this point in the history
* inline tgb controls

* linting

* linting

---------

Co-authored-by: Fred Lefévère-Laoide <90181748+FredLL-Avaiga@users.noreply.github.com>
  • Loading branch information
dinhlongviolin1 and FredLL-Avaiga authored Sep 11, 2024
1 parent fdc3e45 commit 0d76d32
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions taipy/gui/builder/_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def __init__(self, *args, **kwargs) -> None:

if args and self._DEFAULT_PROPERTY != "":
self._properties = {self._DEFAULT_PROPERTY: args[0]}
# special attribute for inline
self._is_inline = kwargs.pop("inline", False)
self._properties.update(kwargs)
self.parse_properties()

Expand Down Expand Up @@ -264,10 +266,11 @@ def __init__(self, *args, **kwargs): # do not remove as it could break the sear
def _render(self, gui: "Gui") -> str:
self._evaluate_lambdas(gui)
el = _BuilderFactory.create_element(gui, self._ELEMENT_NAME, self._deepcopy_properties())
inline_block = 'style="display:inline-block;"' if self._is_inline else ""
return (
f"<div>{el[0]}</{el[1]}></div>"
f"<div {inline_block}>{el[0]}</{el[1]}></div>"
if f"<{el[1]}" in el[0] and f"</{el[1]}" not in el[0]
else f"<div>{el[0]}</div>"
else f"<div {inline_block}>{el[0]}</div>"
)

def __enter__(self):
Expand Down

0 comments on commit 0d76d32

Please sign in to comment.