99 Box ,
1010 VegaChart ,
1111 Table ,
12- IconButton ,
1312 Button ,
1413)
1514from chartlets .components .table import TableColumn , TableRow
@@ -47,12 +46,21 @@ def render_panel(
4746 ]
4847
4948 open_button = Button (
50- id = "open_button" , startIcon = "Insights " , text = "Please click here!"
49+ id = "open_button" , text = "Show component! " , style = { "margin" : "20px" }
5150 )
5251
53- table = Table (id = "table" , rows = rows , columns = columns , hover = True )
52+ table = Table (
53+ id = "table" ,
54+ rows = rows ,
55+ columns = columns ,
56+ hover = True ,
57+ style = {"width" : "250px" , "margin" : "30px" },
58+ )
59+
60+ info_text = Typography (
61+ id = "info_text" , children = ["This is a text." ], style = {"color" : "pink" }
62+ )
5463
55- info_text = Typography (id = "info_text" , children = ["This is a text." ])
5664 chart = VegaChart (
5765 id = "chart" ,
5866 chart = (
@@ -61,15 +69,32 @@ def render_panel(
6169 .encode (x = alt .X ("x:N" , title = "x" ), y = alt .Y ("a:Q" , title = "a" ))
6270 .properties (width = 290 , height = 300 , title = "Vega charts" )
6371 ),
64- style = {"flexGrow" : 1 },
72+ style = {"flexGrow" : 1 , "margin" : "10px" },
6573 )
6674
67- tab1 = Tab (id = "tab1" , label = "Tab 1" , children = [table ])
75+ tab1 = Tab (
76+ id = "tab1" ,
77+ label = "Tab 1" ,
78+ children = [table ],
79+ style = {"backgroundColor" : "darkblue" , "padding" : "1px" },
80+ )
6881 tab2 = Tab (id = "tab2" , label = "Tab 2" , children = [info_text ])
69- tab3 = Tab (id = "tab3" , label = "Tab 3" , children = [chart ])
82+ tab3 = Tab (
83+ id = "tab3" ,
84+ label = "Tab 3" ,
85+ children = [chart ],
86+ style = {
87+ "color" : "darkseagreen" ,
88+ "backgroundColor" : "darkgreen" ,
89+ "padding" : "1px" ,
90+ },
91+ )
7092
7193 tabs = Tabs (
72- id = "tabs" , value = 0 , children = [tab1 , tab2 , tab3 ], style = {"visibility" : "hidden" }
94+ id = "tabs" ,
95+ value = 0 ,
96+ children = [tab1 , tab2 , tab3 ],
97+ style = {"visibility" : "hidden" },
7398 )
7499
75100 return Box (
@@ -84,6 +109,22 @@ def render_panel(
84109
85110
86111# noinspection PyUnusedLocal
87- @panel .callback (Input ("open_button" , "clicked" ), Output ("tabs" , "style" ))
88- def tabs_on_open (ctx : Context , button ) -> dict :
89- return {"visibility" : "visible" }
112+ @panel .callback (
113+ Input ("open_button" , "clicked" ),
114+ Input ("tabs" , "style" ),
115+ Output ("tabs" , "style" ),
116+ Output ("open_button" , "text" ),
117+ )
118+ def tabs_on_open (ctx : Context , button , style ) -> tuple [dict , str ]:
119+ visibility = style ["visibility" ]
120+
121+ if visibility == "hidden" :
122+ return (
123+ {** style , "visibility" : "visible" },
124+ "Hide component!" ,
125+ )
126+ else :
127+ return (
128+ {** style , "visibility" : "hidden" },
129+ "Show component!" ,
130+ )
0 commit comments