sas.qtgui.Utilities.Reports package¶
Subpackages¶
Submodules¶
sas.qtgui.Utilities.Reports.ReportDialog module¶
- class sas.qtgui.Utilities.Reports.ReportDialog.ReportDialog(report_data: ReportData, parent: QObject | None = None)¶
Bases:
QDialog
,Ui_ReportDialogUI
- __doc__ = None¶
- __init__(self, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) None ¶
Initialize self. See help(type(self)) for accurate signature.
- __module__ = 'sas.qtgui.Utilities.Reports.ReportDialog'¶
- onPrint()¶
Display the print dialog and send the report to printer
- onSave()¶
Display the Save As… prompt and save the report if instructed so
- static save_pdf(data, filename)¶
Create a PDF file from html source string. Returns True is the file creation was successful. : data: html string : filename: name of file to be saved
- setupDialog(output=None)¶
Display the HTML content in the browser.
- staticMetaObject = PySide6.QtCore.QMetaObject("ReportDialog" inherits "QDialog": )¶
- static write_string(string, filename)¶
Write string to file
sas.qtgui.Utilities.Reports.reportdata module¶
- class sas.qtgui.Utilities.Reports.reportdata.ReportData(html: str = '<html><body>No Data</body></html>', text: str = 'No data')¶
Bases:
object
- __annotations__ = {'html': <class 'str'>, 'text': <class 'str'>}¶
- __dataclass_fields__ = {'html': Field(name='html',type=<class 'str'>,default='<html><body>No Data</body></html>',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'text': Field(name='text',type=<class 'str'>,default='No data',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}¶
- __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)¶
- __dict__ = mappingproxy({'__module__': 'sas.qtgui.Utilities.Reports.reportdata', '__annotations__': {'html': <class 'str'>, 'text': <class 'str'>}, 'html': '<html><body>No Data</body></html>', 'text': 'No data', '__dict__': <attribute '__dict__' of 'ReportData' objects>, '__weakref__': <attribute '__weakref__' of 'ReportData' objects>, '__doc__': "ReportData(html: str = '<html><body>No Data</body></html>', text: str = 'No data')", '__dataclass_params__': _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False), '__dataclass_fields__': {'html': Field(name='html',type=<class 'str'>,default='<html><body>No Data</body></html>',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'text': Field(name='text',type=<class 'str'>,default='No data',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}, '__init__': <function ReportData.__init__>, '__repr__': <function ReportData.__repr__>, '__eq__': <function ReportData.__eq__>, '__hash__': None, '__match_args__': ('html', 'text')})¶
- __doc__ = "ReportData(html: str = '<html><body>No Data</body></html>', text: str = 'No data')"¶
- __eq__(other)¶
Return self==value.
- __hash__ = None¶
- __init__(html: str = '<html><body>No Data</body></html>', text: str = 'No data') None ¶
- __match_args__ = ('html', 'text')¶
- __module__ = 'sas.qtgui.Utilities.Reports.reportdata'¶
- __repr__()¶
Return repr(self).
- __weakref__¶
list of weak references to the object
- html: str = '<html><body>No Data</body></html>'¶
- text: str = 'No data'¶
sas.qtgui.Utilities.Reports.reports module¶
- class sas.qtgui.Utilities.Reports.reports.ReportBase(title: str, style_link: str | None = None, show_figure_section_title=True, show_param_section_title=True)¶
Bases:
object
- __dict__ = mappingproxy({'__module__': 'sas.qtgui.Utilities.Reports.reports', '__init__': <function ReportBase.__init__>, 'add_data_details': <function ReportBase.add_data_details>, 'add_plot': <function ReportBase.add_plot>, '_add_plot_svg': <function ReportBase._add_plot_svg>, '_add_plot_png': <function ReportBase._add_plot_png>, 'add_image_from_file': <function ReportBase.add_image_from_file>, 'add_image_from_bytes': <function ReportBase.add_image_from_bytes>, 'add_table_dict': <function ReportBase.add_table_dict>, 'add_table': <function ReportBase.add_table>, 'text': <property object>, 'html': <property object>, 'report_data': <property object>, 'save_html': <function ReportBase.save_html>, 'save_text': <function ReportBase.save_text>, 'save_pdf': <function ReportBase.save_pdf>, '__dict__': <attribute '__dict__' of 'ReportBase' objects>, '__weakref__': <attribute '__weakref__' of 'ReportBase' objects>, '__doc__': None, '__annotations__': {}})¶
- __doc__ = None¶
- __init__(title: str, style_link: str | None = None, show_figure_section_title=True, show_param_section_title=True)¶
Holds a (DOM) representation of a report, the details that need to go into the report can be added with reasonably simple calls, e.g. add_table, add_plot
- Parameters:
title – Report title
style_link – If provided will set style in the html to the specified URL, rather than embedding contents from local report_style.css
- Show_figure_section_title:
Add h2 tag for figure section
- Show_figure_section_title:
Add h2 tag for parameters section
- __module__ = 'sas.qtgui.Utilities.Reports.reports'¶
- __weakref__¶
list of weak references to the object
- _add_plot_png(fig)¶
- _add_plot_svg(fig)¶
- add_image_from_bytes(bytes: BytesIO, file_type='png')¶
Add an image from a BytesIO object
- add_image_from_file(filename: str)¶
Add image to report from a source file
- add_plot(fig, image_type='png', figure_title: str | None = None)¶
Add a plot to the report
- Parameters:
fig – matplotlib.figure.Figure, Matplotlib figure object to add
image_type – str, type of embedded image - ‘svg’ or ‘png’, defaults to ‘svg’
figure_title – Optional[str] - Optionally add an html header tag, defaults to None
- Raises:
ValueError – if image_type is bad
- add_table(data: List[List[Any]], titles: Iterable[str] | None = None, target_tag='model-parameters', column_prefix='column')¶
Add a table of parameters to the report
- property html: str¶
A string containing the html of the document
- property report_data: ReportData¶
- save_html(filename: str)¶
- save_pdf(filename: str)¶
- save_text(filename: str)¶
- property text: str¶
Text version of the document (actually RST)
- sas.qtgui.Utilities.Reports.reports.main()¶
This can be run locally without sasview to make it easy to adjust the report layout/styling, it will generate a report with some arbitrary data
- class sas.qtgui.Utilities.Reports.reports.pretty_units(*args, **kwargs)¶
Bases:
span
HTML tag for units, prettifies angstroms, inverse angstroms and inverse cm TODO: Should be replaced when there is a better way of handling units
- __doc__ = ' HTML tag for units, prettifies angstroms, inverse angstroms and inverse cm\n TODO: Should be replaced when there is a better way of handling units'¶
- __init__(unit_string: str, *args, **kwargs)¶
Creates a new html tag instance.
- __module__ = 'sas.qtgui.Utilities.Reports.reports'¶
- tagname = 'span'¶