-
Notifications
You must be signed in to change notification settings - Fork 80
silx.gui.plot: Improved StatsWidget display slightly, especially for 1D plots #4361
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 all commits
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 |
|---|---|---|
|
|
@@ -633,6 +633,8 @@ def setStats(self, statsHandler): | |
| horizontalHeader = self.horizontalHeader() | ||
| horizontalHeader.setSectionResizeMode(qt.QHeaderView.ResizeToContents) | ||
|
|
||
| horizontalHeader.setStretchLastSection(True) | ||
|
|
||
| self._updateItemObserve() | ||
|
|
||
| def setPlot(self, plot): | ||
|
|
@@ -817,6 +819,7 @@ def _addItem(self, item): | |
| for column, tableItem in enumerate(tableItems): | ||
| tableItem.setData(qt.Qt.UserRole, _Container(item)) | ||
| tableItem.setFlags(qt.Qt.ItemIsEnabled | qt.Qt.ItemIsSelectable) | ||
| tableItem.setTextAlignment(qt.Qt.AlignHCenter | qt.Qt.AlignVCenter) | ||
|
Member
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. 👍 |
||
| self.setItem(row, column, tableItem) | ||
|
|
||
| # Update table items content | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -217,6 +217,8 @@ def calculate( | |
| data_changed=data_changed, | ||
| roi_changed=roi_changed, | ||
| ) | ||
| for resName, resValue in list(res.items()): | ||
| res[resName] = self.format(resName, res[resName]) | ||
| for resName, resValue in res.items(): | ||
| if isinstance(resValue, tuple) and len(resValue) == 1: | ||
| resValue = resValue[0] | ||
|
Comment on lines
+220
to
+222
Member
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. The problem with this approach is that we won't be able to display tuples as results of stats. But we need it.
The simplest alternative is probably to create you own class MyStatCoordMin(StatCoordMin):
def calculate(self, context):
result = super().calculate(context)
return result[0]
Contributor
Author
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. That's why I added the check
Member
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. The Given the current design, I think there are two approaches to address your use case:
plot = Plot2D()
stats = [
(StatCoordMin(), "{0:.2f}"),
]
plot.getStatsWidget().setStats(stats) |
||
| res[resName] = self.format(resName, resValue) | ||
| return res | ||

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.
👍