@@ -229,7 +229,7 @@ def get_row_key(self, row):
229229 'Key determines if a result needs to be recomputed or not'
230230 raise NotImplementedError ()
231231
232- def sync_table_colors (self , table ):
232+ def set_table_colors (self , table ):
233233 template = 'row == {i} ? {reduced_color} : '
234234 expr = ''
235235 for i , (_ , row ) in enumerate (table .data .iterrows ()):
@@ -239,23 +239,23 @@ def sync_table_colors(self, table):
239239 expr += "default_value"
240240 table .default_renderer .background_color = VegaExpr (expr )
241241
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+
242247 def set_result (self , metadata , result ):
243248 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 )
247252
248253 def log (self , message ):
249254 out = widgets .Output ()
250255 with out :
251256 display (message )
252257 self .text_log .children = (out , * self .text_log .children )
253258
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-
259259 def sync (self , * _ ):
260260 db = {}
261261 # db["settings"] = self.load_settings()
@@ -277,9 +277,9 @@ def sync(self, *_):
277277 self .set_table_height (self .runs_table )
278278 self .set_table_height (self .reduction_table )
279279 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 )
283283
284284 @property
285285 def path (self ):
@@ -406,12 +406,14 @@ def add_row(_):
406406 ]
407407 )
408408 # To avoid a flickering scrollbar
409+ # - increase table height with some margin before adding row
410+ # - adjust able height afterwards
409411 self .set_table_height (self .custom_reduction_table , extra = 25 )
410412 self .custom_reduction_table .data = pd .concat (
411413 [self .custom_reduction_table .data , row ]
412414 )
413415 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 )
415417
416418 def delete_row (_ ):
417419 self .log ("delete row" )
@@ -643,7 +645,7 @@ def sync_custom_reduction_table(self):
643645 else tuple (x .split (',' ))
644646 )
645647 self .custom_reduction_table .data = df
646- self .sync_table_colors (self .custom_reduction_table )
648+ self .set_table_colors (self .custom_reduction_table )
647649
648650 def display_results (self ):
649651 df = self .get_selected_rows ()
0 commit comments