-
Notifications
You must be signed in to change notification settings - Fork 2
fix #43 (autoresize) #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -537,8 +537,10 @@ def __init__(self, parent, data, readonly=False, bg_value=None, bg_gradient=None | |
self.view_xlabels.horizontalHeader().sectionResized.connect(self.view_data.updateSectionWidth) | ||
self.view_ylabels.verticalHeader().sectionResized.connect(self.view_data.updateSectionHeight) | ||
# Synchronize auto-resizing | ||
self.view_xlabels.horizontalHeader().sectionHandleDoubleClicked.connect(self.resizeColumnToContents) | ||
self.view_ylabels.verticalHeader().sectionHandleDoubleClicked.connect(self.resizeRowToContents) | ||
self.view_axes.horizontalHeader().sectionHandleDoubleClicked.connect(self.resizeAxesColumnToContents) | ||
self.view_xlabels.horizontalHeader().sectionHandleDoubleClicked.connect(self.resizeDataColumnToContents) | ||
self.view_axes.verticalHeader().sectionHandleDoubleClicked.connect(self.resizeAxesRowToContents) | ||
self.view_ylabels.verticalHeader().sectionHandleDoubleClicked.connect(self.resizeDataRowToContents) | ||
|
||
# synchronize specific methods | ||
self.view_axes.allSelected.connect(self.view_data.selectAll) | ||
|
@@ -718,6 +720,7 @@ def set_data(self, data, bg_gradient=None, bg_value=None): | |
self.data_adapter.update_filtered_data({}) | ||
|
||
# reset default size | ||
self.view_axes.set_default_size() | ||
self.view_ylabels.set_default_size() | ||
self.view_xlabels.set_default_size() | ||
self.view_data.set_default_size() | ||
|
@@ -841,18 +844,35 @@ def _data_digits(self, data, maxdigits=6): | |
return maxdigits | ||
|
||
def autofit_columns(self): | ||
self.view_axes.autofit_columns() | ||
for column in range(self.model_axes.columnCount()): | ||
self.resizeAxesColumnToContents(column) | ||
self.view_xlabels.autofit_columns() | ||
for column in range(self.model_xlabels.columnCount()): | ||
self.resizeColumnToContents(column) | ||
self.resizeDataColumnToContents(column) | ||
|
||
def resizeColumnToContents(self, column): | ||
def resizeAxesColumnToContents(self, column): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename to resize_axes_column_to_contents? |
||
# must be connected to view_axes.horizontalHeader().sectionHandleDoubleClicked signal | ||
width = max(self.view_axes.horizontalHeader().sectionSize(column), | ||
self.view_ylabels.sizeHintForColumn(column)) | ||
# no need to call resizeSection on view_ylabels (see synchronization lines in init) | ||
self.view_axes.horizontalHeader().resizeSection(column, width) | ||
|
||
def resizeDataColumnToContents(self, column): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename to resize_xlabels_column_to_contents because this works first on the view_xlabels not view_data?
|
||
# must be connected to view_labels.horizontalHeader().sectionHandleDoubleClicked signal | ||
width = max(self.view_xlabels.horizontalHeader().sectionSize(column), | ||
self.view_data.sizeHintForColumn(column)) | ||
# no need to call resizeSection on view_data (see synchronization lines in init) | ||
self.view_xlabels.horizontalHeader().resizeSection(column, width) | ||
|
||
def resizeRowToContents(self, row): | ||
def resizeAxesRowToContents(self, row): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename to resize_axes_row_to_contents? |
||
# must be connected to view_axes.verticalHeader().sectionHandleDoubleClicked | ||
height = max(self.view_axes.verticalHeader().sectionSize(row), | ||
self.view_xlabels.sizeHintForRow(row)) | ||
# no need to call resizeSection on view_xlabels (see synchronization lines in init) | ||
self.view_axes.verticalHeader().resizeSection(row, height) | ||
|
||
def resizeDataRowToContents(self, row): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idem |
||
# must be connected to view_labels.verticalHeader().sectionHandleDoubleClicked | ||
height = max(self.view_xlabels.verticalHeader().sectionSize(row), | ||
self.view_data.sizeHintForRow(row)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be nice to give meaningful names to those arrays: either what do they test, or what is their "special" characteristic, eg: