Skip to content

Commit ff41227

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

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

larray_editor/api.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,13 @@ def restore_display_hook():
338338
arr7 = la.from_lists([['a', 1, 2, 3],
339339
[ '', 1664780726569649730, -9196963249083393206, -7664327348053294350]])
340340

341+
# test autoresizing
342+
arr8 = la.zeros('a=a_long_label,another_long_label')
343+
341344
# compare(arr3, arr4, arr5, arr6)
342345

343346
# view(la.stack((arr3, arr4), la.Axis('arrays=arr3,arr4')))
344-
ses = la.Session(arr2=arr2, arr3=arr3, arr4=arr4, arr5=arr5, arr6=arr6, arr7=arr7,
347+
ses = la.Session(arr2=arr2, arr3=arr3, arr4=arr4, arr5=arr5, arr6=arr6, arr7=arr7, arr8=arr8,
345348
data2=data2, data3=data3)
346349

347350
# from larray.tests.common import abspath
@@ -358,9 +361,9 @@ def restore_display_hook():
358361
# edit('fake_path')
359362
# edit(REOPEN_LAST_FILE)
360363

361-
edit(arr2)
364+
edit(ses)
362365
# compare(la.Session(arr2=arr2, arr3=arr3), la.Session(arr2=arr2 + 1.0, arr3=arr3 + 1.0))
363-
compare(arr3, arr3 + la.ndrange(arr3.axes))
366+
# compare(arr3, arr3 + la.ndrange(arr3.axes))
364367

365368
# s = la.local_arrays()
366369
# view(s)

larray_editor/arraywidget.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -823,15 +823,17 @@ def autofit_columns(self):
823823
self.view_data.autofit_columns()
824824

825825
def resizeColumnToContents(self, column):
826-
width = max(self.view_xlabels.horizontalHeader().sectionSizeHint(column),
826+
# must be connected to view_labels.horizontalHeader().sectionHandleDoubleClicked signal
827+
width = max(self.view_xlabels.horizontalHeader().sectionSize(column),
827828
self.view_data.sizeHintForColumn(column))
828-
self.view_data.horizontalHeader().resizeSection(column, width)
829+
# no need to call resizeSection on view_data (see synchronization lines in init)
829830
self.view_xlabels.horizontalHeader().resizeSection(column, width)
830831

831832
def resizeRowToContents(self, row):
832-
height = max(self.view_xlabels.verticalHeader().sectionSizeHint(row),
833+
# must be connected to view_labels.verticalHeader().sectionHandleDoubleClicked
834+
height = max(self.view_xlabels.verticalHeader().sectionSize(row),
833835
self.view_data.sizeHintForRow(row))
834-
self.view_data.verticalHeader().resizeSection(row, height)
836+
# no need to call resizeSection on view_data (see synchronization lines in init)
835837
self.view_ylabels.verticalHeader().resizeSection(row, height)
836838

837839
@property

0 commit comments

Comments
 (0)