Reputation: 17
The status shown on the page has a red and a green color (https://docs.taipy.io/en/latest/manuals/gui/controls/). How do I make them have two or more different colors if you have more than two status. Below is the code where clicking on a toggle changes the status but everything is the same color. The id of "id=statuslog" I understand is for the three. Would it be using individual IDs "FT1", "FT2" and "FT3"? I had create a css file with the id "statuslog" but the style is the same for all items of value_tgg
Code: from taipy import Gui
value_tgg=[('TG1', 'Choice 1'), ('TG2', 'Choice 2'), ('TG3', 'Choice 3')]
value_tgg_choice=value_tgg[0]
val_status1= [('FT1', 'Recording'), ('FT2', 'Recorded'), ('FT3', 'Failed')]
val_status_choice1=val_status1[0]
page1_md="""
## TESTE
<|{val_status_choice1}|status|lov={val_status1}|id=statuslog|>
<|{value_tgg_choice}|toggle|lov={value_tgg}|on_change={on_value_tgg}|>
"""
def on_value_tgg(state, id, action):
print(state.value_tgg_choice)
if state.value_tgg_choice[1]=='Choice 1':
state.val_status_choice1=state.val_status1[1]
print('1')
elif state.value_tgg_choice[1]=='Choice 2':
state.val_status_choice1=state.val_status1[2]
print('2')
elif state.value_tgg_choice[1]=='Choice 3':
state.val_status_choice1=state.val_status1[0]
print('3')
Upvotes: 0
Views: 148
Reputation: 1521
Modifying the status color is determined by the initial element of the tuple passed to the toggle.
The default color for this visual component is blue.
In the code provided, a toggle is used to select from a list of tuples, where the first element dictates a unique color each time.
from taipy import Gui
list_toggle = [('E', 'Recording'),
('S', 'Recorded'),
('I', 'Failed'),
('W', 'Warning')]
value_toggle = list_toggle[0]
page1_md = """
# Status
<|{value_toggle}|status|>
<|{value_toggle}|toggle|lov={list_toggle}|>
"""
Gui(page1_md).run()
A better documentation is on the way to explain this behavior.
Upvotes: 0