Skip to content

Commit 93ce4db

Browse files
FredLL-AvaigaFred Lefévère-LaoideFabienLelaquais
authored
part style property support (#2670)
* part style property support resolves #2574 * Update taipy/gui/viselements.json Co-authored-by: Fabien Lelaquais <86590727+FabienLelaquais@users.noreply.github.com> --------- Co-authored-by: Fred Lefévère-Laoide <Fred.Lefevere-Laoide@Taipy.io> Co-authored-by: Fabien Lelaquais <86590727+FabienLelaquais@users.noreply.github.com>
1 parent f505727 commit 93ce4db

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

taipy/gui/_renderers/builder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,4 +1200,5 @@ def _build_to_string(self):
12001200
el_str = el_str.replace("<?xml version='1.0' encoding='utf8'?>\n", "")
12011201
el_str = el_str.replace("/>", ">")
12021202
el_str = el_str.replace(">style</TaipyStyle>", "/>")
1203+
el_str = el_str.replace(f"</{self.__element_name}>", "")
12031204
return el_str, self.__element_name

taipy/gui/viselements.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,6 +2375,11 @@
23752375
"name": "hover_text",
23762376
"type": "dynamic(str)",
23772377
"doc": "The text that is displayed when the user hovers over the element."
2378+
},
2379+
{
2380+
"name": "style",
2381+
"type": "dict",
2382+
"doc": "TODO: A dict representing a css description."
23782383
}
23792384
]
23802385
}

tests/gui/builder/control/test_part.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ def test_part_builder_1(gui: Gui, helpers):
1919
tgb.text(value="This is a part") # type: ignore[attr-defined]
2020
expected_list = ["<Part", "This is a part"]
2121
helpers.test_control_builder(gui, page, expected_list)
22+
23+
def test_part_builder_with_style(gui: Gui, helpers):
24+
with tgb.Page(frame=None) as page:
25+
with tgb.part(class_name="class1", style={"background": "red"}): # type: ignore[attr-defined]
26+
tgb.text(value="This is a part") # type: ignore[attr-defined]
27+
expected_list = ["<Part", "This is a part", '<TaipyStyle className="tpcss-']
28+
helpers.test_control_builder(gui, page, expected_list)

0 commit comments

Comments
 (0)