@@ -229,7 +229,7 @@ def get_row_key(self, row):
229
229
'Key determines if a result needs to be recomputed or not'
230
230
raise NotImplementedError ()
231
231
232
- def sync_table_colors (self , table ):
232
+ def set_table_colors (self , table ):
233
233
template = 'row == {i} ? {reduced_color} : '
234
234
expr = ''
235
235
for i , (_ , row ) in enumerate (table .data .iterrows ()):
@@ -239,23 +239,23 @@ def sync_table_colors(self, table):
239
239
expr += "default_value"
240
240
table .default_renderer .background_color = VegaExpr (expr )
241
241
242
+ @staticmethod
243
+ def set_table_height (table , extra = 0 ):
244
+ height = (len (table .data ) + 1 ) * (table .base_row_size + 1 ) + 5 + extra
245
+ table .layout .height = f'{ height } px'
246
+
242
247
def set_result (self , metadata , result ):
243
248
self .results [self .get_row_key (metadata )] = result
244
- self .sync_table_colors (self .reduction_table )
245
- self .sync_table_colors (self .custom_reduction_table )
246
- self .sync_table_colors (self .reference_table )
249
+ self .set_table_colors (self .reduction_table )
250
+ self .set_table_colors (self .custom_reduction_table )
251
+ self .set_table_colors (self .reference_table )
247
252
248
253
def log (self , message ):
249
254
out = widgets .Output ()
250
255
with out :
251
256
display (message )
252
257
self .text_log .children = (out , * self .text_log .children )
253
258
254
- @staticmethod
255
- def set_table_height (table , extra = 0 ):
256
- height = (len (table .data ) + 1 ) * (table .base_row_size + 1 ) + 5 + extra
257
- table .layout .height = f'{ height } px'
258
-
259
259
def sync (self , * _ ):
260
260
db = {}
261
261
# db["settings"] = self.load_settings()
@@ -277,9 +277,9 @@ def sync(self, *_):
277
277
self .set_table_height (self .runs_table )
278
278
self .set_table_height (self .reduction_table )
279
279
self .set_table_height (self .custom_reduction_table )
280
- self .sync_table_colors (self .reduction_table )
281
- self .sync_table_colors (self .custom_reduction_table )
282
- self .sync_table_colors (self .reference_table )
280
+ self .set_table_colors (self .reduction_table )
281
+ self .set_table_colors (self .custom_reduction_table )
282
+ self .set_table_colors (self .reference_table )
283
283
284
284
@property
285
285
def path (self ):
@@ -406,12 +406,14 @@ def add_row(_):
406
406
]
407
407
)
408
408
# To avoid a flickering scrollbar
409
+ # - increase table height with some margin before adding row
410
+ # - adjust able height afterwards
409
411
self .set_table_height (self .custom_reduction_table , extra = 25 )
410
412
self .custom_reduction_table .data = pd .concat (
411
413
[self .custom_reduction_table .data , row ]
412
414
)
413
415
self .set_table_height (self .custom_reduction_table )
414
- self .sync_table_colors (self .custom_reduction_table )
416
+ self .set_table_colors (self .custom_reduction_table )
415
417
416
418
def delete_row (_ ):
417
419
self .log ("delete row" )
@@ -643,7 +645,7 @@ def sync_custom_reduction_table(self):
643
645
else tuple (x .split (',' ))
644
646
)
645
647
self .custom_reduction_table .data = df
646
- self .sync_table_colors (self .custom_reduction_table )
648
+ self .set_table_colors (self .custom_reduction_table )
647
649
648
650
def display_results (self ):
649
651
df = self .get_selected_rows ()
0 commit comments