Skip to content

Commit ee166d0

Browse files
committed
fix #43 : autoresize of rows/columns takes the maximum height/width between data and labels
1 parent 36c04cd commit ee166d0

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

larray_editor/arraywidget.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -815,14 +815,16 @@ def autofit_columns(self):
815815
self.view_data.autofit_columns()
816816

817817
def resizeColumnToContents(self, column):
818-
self.view_data.resizeColumnToContents(column)
819-
width = self.view_data.columnWidth(column)
820-
self.view_xlabels.setColumnWidth(column, width)
818+
width = max(self.view_xlabels.horizontalHeader().sectionSizeHint(column),
819+
self.view_data.sizeHintForColumn(column))
820+
self.view_data.horizontalHeader().resizeSection(column, width)
821+
self.view_xlabels.horizontalHeader().resizeSection(column, width)
821822

822823
def resizeRowToContents(self, row):
823-
self.view_data.resizeRowToContents(row)
824-
height = self.view_data.rowHeight(row)
825-
self.view_ylabels.setRowHeight(row, height)
824+
height = max(self.view_xlabels.verticalHeader().sectionSizeHint(row),
825+
self.view_data.sizeHintForRow(row))
826+
self.view_data.verticalHeader().resizeSection(row, height)
827+
self.view_ylabels.verticalHeader().resizeSection(row, height)
826828

827829
@property
828830
def dirty(self):

0 commit comments

Comments
 (0)