@@ -537,8 +537,10 @@ def __init__(self, parent, data, readonly=False, bg_value=None, bg_gradient=None
537
537
self .view_xlabels .horizontalHeader ().sectionResized .connect (self .view_data .updateSectionWidth )
538
538
self .view_ylabels .verticalHeader ().sectionResized .connect (self .view_data .updateSectionHeight )
539
539
# Synchronize auto-resizing
540
- self .view_xlabels .horizontalHeader ().sectionHandleDoubleClicked .connect (self .resizeColumnToContents )
541
- self .view_ylabels .verticalHeader ().sectionHandleDoubleClicked .connect (self .resizeRowToContents )
540
+ self .view_axes .horizontalHeader ().sectionHandleDoubleClicked .connect (self .resize_axes_column_to_contents )
541
+ self .view_xlabels .horizontalHeader ().sectionHandleDoubleClicked .connect (self .resize_xlabels_column_to_contents )
542
+ self .view_axes .verticalHeader ().sectionHandleDoubleClicked .connect (self .resize_axes_row_to_contents )
543
+ self .view_ylabels .verticalHeader ().sectionHandleDoubleClicked .connect (self .resize_ylabels_row_to_contents )
542
544
543
545
# synchronize specific methods
544
546
self .view_axes .allSelected .connect (self .view_data .selectAll )
@@ -718,6 +720,7 @@ def set_data(self, data, bg_gradient=None, bg_value=None):
718
720
self .data_adapter .update_filtered_data ({})
719
721
720
722
# reset default size
723
+ self .view_axes .set_default_size ()
721
724
self .view_ylabels .set_default_size ()
722
725
self .view_xlabels .set_default_size ()
723
726
self .view_data .set_default_size ()
@@ -841,20 +844,37 @@ def _data_digits(self, data, maxdigits=6):
841
844
return maxdigits
842
845
843
846
def autofit_columns (self ):
847
+ self .view_axes .autofit_columns ()
848
+ for column in range (self .model_axes .columnCount ()):
849
+ self .resize_axes_column_to_contents (column )
844
850
self .view_xlabels .autofit_columns ()
845
851
for column in range (self .model_xlabels .columnCount ()):
846
- self .resizeColumnToContents (column )
852
+ self .resize_xlabels_column_to_contents (column )
847
853
848
- def resizeColumnToContents (self , column ):
854
+ def resize_axes_column_to_contents (self , column ):
855
+ # must be connected to view_axes.horizontalHeader().sectionHandleDoubleClicked signal
856
+ width = max (self .view_axes .horizontalHeader ().sectionSize (column ),
857
+ self .view_ylabels .sizeHintForColumn (column ))
858
+ # no need to call resizeSection on view_ylabels (see synchronization lines in init)
859
+ self .view_axes .horizontalHeader ().resizeSection (column , width )
860
+
861
+ def resize_xlabels_column_to_contents (self , column ):
849
862
# must be connected to view_labels.horizontalHeader().sectionHandleDoubleClicked signal
850
863
width = max (self .view_xlabels .horizontalHeader ().sectionSize (column ),
851
864
self .view_data .sizeHintForColumn (column ))
852
865
# no need to call resizeSection on view_data (see synchronization lines in init)
853
866
self .view_xlabels .horizontalHeader ().resizeSection (column , width )
854
867
855
- def resizeRowToContents (self , row ):
868
+ def resize_axes_row_to_contents (self , row ):
869
+ # must be connected to view_axes.verticalHeader().sectionHandleDoubleClicked
870
+ height = max (self .view_axes .verticalHeader ().sectionSize (row ),
871
+ self .view_xlabels .sizeHintForRow (row ))
872
+ # no need to call resizeSection on view_xlabels (see synchronization lines in init)
873
+ self .view_axes .verticalHeader ().resizeSection (row , height )
874
+
875
+ def resize_ylabels_row_to_contents (self , row ):
856
876
# must be connected to view_labels.verticalHeader().sectionHandleDoubleClicked
857
- height = max (self .view_xlabels .verticalHeader ().sectionSize (row ),
877
+ height = max (self .view_ylabels .verticalHeader ().sectionSize (row ),
858
878
self .view_data .sizeHintForRow (row ))
859
879
# no need to call resizeSection on view_data (see synchronization lines in init)
860
880
self .view_ylabels .verticalHeader ().resizeSection (row , height )
0 commit comments