@@ -109,6 +109,9 @@ def setup_and_check(self, data, title='', readonly=False, minvalue=None, maxvalu
109
109
110
110
self ._listwidget = QListWidget (self )
111
111
self ._listwidget .currentItemChanged .connect (self .on_item_changed )
112
+ # this is a workaround for the fact that no currentItemChanged signal is emitted when no item was selected
113
+ # before
114
+ self ._listwidget .itemSelectionChanged .connect (self .on_selection_changed )
112
115
self ._listwidget .setMinimumWidth (45 )
113
116
114
117
del_item_shortcut = QShortcut (QKeySequence (Qt .Key_Delete ), self ._listwidget )
@@ -417,6 +420,14 @@ def ipython_cell_executed(self):
417
420
if isinstance (cur_output , matplotlib .axes .Subplot ) and 'inline' not in matplotlib .get_backend ():
418
421
show_figure (self , cur_output .figure )
419
422
423
+ def on_selection_changed (self , * args , ** kwargs ):
424
+ selected = self ._listwidget .selectedItems ()
425
+ if selected :
426
+ assert len (selected ) == 1
427
+ selected_item = selected [0 ]
428
+ assert isinstance (selected_item , QListWidgetItem )
429
+ self .on_item_changed (selected_item , None )
430
+
420
431
def on_item_changed (self , curr , prev ):
421
432
if curr is not None :
422
433
name = str (curr .text ())
@@ -457,12 +468,11 @@ def update_title(self):
457
468
self .setWindowTitle (' - ' .join (title ))
458
469
459
470
def set_current_array (self , array , name ):
460
- self .current_array = array
461
- self .arraywidget .set_data (array )
462
- if name != '<expr>' and name != self .current_array_name :
463
- self .arraywidget .set_filters ()
471
+ if array is not self .current_array :
472
+ self .current_array = array
473
+ self .arraywidget .set_data (array )
464
474
self .current_array_name = name
465
- self .update_title ()
475
+ self .update_title ()
466
476
467
477
def _add_arrays (self , arrays ):
468
478
for k , v in arrays .items ():
@@ -501,7 +511,6 @@ def new(self):
501
511
if self ._ask_to_save_if_unsaved_modifications ():
502
512
self ._reset ()
503
513
self .arraywidget .set_data (np .empty (0 ))
504
- self .arraywidget .set_filters ()
505
514
self .set_current_file (None )
506
515
self ._unsaved_modifications = False
507
516
self .statusBar ().showMessage ("Viewer has been reset" , 4000 )
0 commit comments