Skip to content
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

Fitting widget refactor #2651

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ jobs:
- name: Install utilities to build installer
if: ${{ matrix.installer }}
run: |
python -m pip install pyinstaller
python -m pip install pyinstaller==5.13.2

- name: Build sasview with pyinstaller
if: ${{ matrix.installer }}
Expand Down
5 changes: 5 additions & 0 deletions src/sas/qtgui/Perspectives/Fitting/FittingLogic.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def __init__(self, data=None):
if data is not None:
self.data_is_loaded = True
self.setDataProperties()
self.model_parameters = None
self.kernel_module = None
# List of all shell-unique parameters
self.shell_names = []
self.current_shell_displayed = 0

@property
def data(self):
Expand Down
44 changes: 44 additions & 0 deletions src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from PySide6 import QtCore
from PySide6 import QtGui
from PySide6 import QtWidgets

import numpy

Expand Down Expand Up @@ -35,6 +36,28 @@
error_tooltip = 'Error value for fitted parameter'
header_error_caption = 'Error'

class ToolTippedItemModel(QtGui.QStandardItemModel):
"""
Subclass from QStandardItemModel to allow displaying tooltips in
QTableView model.
"""
def __init__(self, parent=None):
QtGui.QStandardItemModel.__init__(self, parent)

def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole):
"""
Displays tooltip for each column's header
:param section:
:param orientation:
:param role:
:return:
"""
if role == QtCore.Qt.ToolTipRole:
if orientation == QtCore.Qt.Horizontal:
return str(self.header_tooltips[section])

return QtGui.QStandardItemModel.headerData(self, section, orientation, role)

def replaceShellName(param_name, value):
"""
Updates parameter name from <param_name>[n_shell] to <param_name>value
Expand Down Expand Up @@ -1008,3 +1031,24 @@ def checkConstraints(symtab, constraints):
else:
return []

def setTableProperties(table):
"""
Setting table properties
"""
# Table properties
table.verticalHeader().setVisible(False)
table.setAlternatingRowColors(True)
table.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding)
table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
table.resizeColumnsToContents()

# Header
header = table.horizontalHeader()
header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
header.ResizeMode(QtWidgets.QHeaderView.Interactive)

# Qt5: the following 2 lines crash - figure out why!
# Resize column 0 and 7 to content
# header.setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
# header.setSectionResizeMode(7, QtWidgets.QHeaderView.ResizeToContents)

Loading