sas.qtgui.Utilities.ModelEditors.TabbedEditor package¶
Subpackages¶
- sas.qtgui.Utilities.ModelEditors.TabbedEditor.UI package
Submodules¶
sas.qtgui.Utilities.ModelEditors.TabbedEditor.ModelEditor module¶
- class sas.qtgui.Utilities.ModelEditors.TabbedEditor.ModelEditor.ModelEditor(parent=None, is_python=True)¶
Bases:
QDialog,Ui_ModelEditorClass describing the “advanced” model editor. This is a simple text browser allowing for editing python and supporting simple highlighting.
- __doc__ = '\n Class describing the "advanced" model editor.\n This is a simple text browser allowing for editing python and\n supporting simple highlighting.\n '¶
- __init__(self, /, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags), *, sizeGripEnabled: bool | None = None, modal: bool | None = None) None¶
Initialize self. See help(type(self)) for accurate signature.
- __module__ = 'sas.qtgui.Utilities.ModelEditors.TabbedEditor.ModelEditor'¶
- addSignals()¶
Respond to signals in the widget
- getModel()¶
Return the current model, as displayed in the window
- modelModified¶
- onEdit()¶
Respond to changes in the text browser.
- setupWidgets()¶
Set up dialog widgets. Here - just the highlighter connected to the text edit.
- staticMetaObject = PySide6.QtCore.QMetaObject("ModelEditor" inherits "QDialog": Methods: #41 type=Signal, signature=modelModified() )¶
sas.qtgui.Utilities.ModelEditors.TabbedEditor.PluginDefinition module¶
- class sas.qtgui.Utilities.ModelEditors.TabbedEditor.PluginDefinition.PluginDefinition(parent: QWidget = None)¶
Bases:
QDialog,Ui_PluginDefinitionClass describing the “simple” plugin editor. This is a simple series of widgets allowing for specifying model form and parameters.
- __doc__ = '\n Class describing the "simple" plugin editor.\n This is a simple series of widgets allowing for specifying\n model form and parameters.\n '¶
- __init__(self, /, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags), *, sizeGripEnabled: bool | None = None, modal: bool | None = None) None¶
Initialize self. See help(type(self)) for accurate signature.
- __module__ = 'sas.qtgui.Utilities.ModelEditors.TabbedEditor.PluginDefinition'¶
- _checkCell(row: int, column: int) bool¶
Check the cell at the particular location (row, column) to see if it has any value.
- _updateParamTable(param_list: [], param_table: QTableWidget)¶
Add subset of parameters sent from model editor to a specific parameter table
- Parameters:
param_list – list of parameters to add to the parameter tables [name, default_value, type]
param_table – A QTableWidget that will be updated with the params from param_list
- addSignals()¶
Define slots for widget signals
- addTooltips()¶
Add the default tooltips to the Iq and form_volume function text boxes
- addWidgets()¶
Initialize various widgets in the dialog
- checkPyModelExists(filename: str) bool¶
Checks if a Python model exists in the user plugin directory and forces enabling Python checkbox if not :param filename: name of the file (without extension)
- enablePyCheckboxSignal¶
- getModel() dict¶
Return the current plugin model
- includePolydisperseFuncsSignal¶
- initializeModel()¶
Define the dictionary for internal data representation
- modelModified¶
- omitPolydisperseFuncsSignal¶
- onDescriptionChanged()¶
Respond to changes in plugin description
- onFormVolumeFunctionChanged()¶
Respond to changes in form volume function body
- onFunctionChanged()¶
Respond to changes in function body
- onGenC()¶
Respond to change in generate C checkbox
- onGenPython()¶
Respond to change in generate Python checkbox
- onOverwrite()¶
Respond to change in file overwrite checkbox
- onParamsChanged(row: int, column: int)¶
Respond to changes in non-polydisperse parameter table
- onParamsPDChanged(row: int, column: int)¶
Respond to changes in polydisperse parameter table
- onPluginNameChanged()¶
Respond to changes in plugin name
- sendNewDescriptionSignal¶
- sendNewFormVolumeSignal¶
- sendNewIqSignal¶
- sendNewParamSignal¶
- setModelTypeCheckBoxEnabledState(filename: str)¶
- staticMetaObject = PySide6.QtCore.QMetaObject("PluginDefinition" inherits "QDialog": Methods: #41 type=Signal, signature=modelModified() #42 type=Signal, signature=omitPolydisperseFuncsSignal() #43 type=Signal, signature=includePolydisperseFuncsSignal() #44 type=Signal, signature=enablePyCheckboxSignal() #45 type=Signal, signature=sendNewParamSignal(QVariantList), parameters=QVariantList #46 type=Signal, signature=sendNewDescriptionSignal(QString), parameters=QString #47 type=Signal, signature=sendNewIqSignal(QString), parameters=QString #48 type=Signal, signature=sendNewFormVolumeSignal(QString), parameters=QString )¶
- updateParamTableFromEditor(param_list: [])¶
Add parameters sent from model editor to the parameter tables
- Parameters:
param_list – list of parameters to add to the parameter tables [name, default_value, type]
- sas.qtgui.Utilities.ModelEditors.TabbedEditor.PluginDefinition.remove_empty_table_rows(tbl: QTableWidget)¶
A helper function to remove empty rows in a PySide Table, if there are more than two empty rows at the end. This function ensures there is always an empty row in the table.
- Parameters:
tbl – A QTableWidget on i rows and j columns.
sas.qtgui.Utilities.ModelEditors.TabbedEditor.TabbedModelEditor module¶
- class sas.qtgui.Utilities.ModelEditors.TabbedEditor.TabbedModelEditor.TabbedModelEditor(parent: QWidget = None, edit_only: bool = False, model: bool = False, load_file: str | None = None)¶
Bases:
QDialog,Ui_TabbedModelEditorModel editor “container” class describing interaction between plugin definition widget and model editor widget. Once the model is defined, it can be saved as a plugin.
- class FunctionBodyExtractor(function_name)¶
Bases:
NodeVisitorClass to extract the body of a function from a model file
- __doc__ = '\n Class to extract the body of a function from a model file\n '¶
- __init__(function_name)¶
- __module__ = 'sas.qtgui.Utilities.ModelEditors.TabbedEditor.TabbedModelEditor'¶
- _check_for_docstring(body: AST) bool¶
A quick check to see if an ast node has a doc string.
- __doc__ = '\n Model editor "container" class describing interaction between\n plugin definition widget and model editor widget.\n Once the model is defined, it can be saved as a plugin.\n '¶
- __init__(self, /, parent: PySide6.QtWidgets.QWidget | None = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags), *, sizeGripEnabled: bool | None = None, modal: bool | None = None) None¶
Initialize self. See help(type(self)) for accurate signature.
- __module__ = 'sas.qtgui.Utilities.ModelEditors.TabbedEditor.TabbedModelEditor'¶
- _checkForErrorsInModelStrs(func_str: str, form_vol_str: str) str | None¶
Helper method to check for errors and returns an error string, if necessary
- _onApply()¶
- addSignals()¶
Define slots for common widget signals
- addTab(filetype: str, name: str)¶
Add a tab to the tab widget :param filetype: filetype of tab to add: “python” or “c” :param name: name to display on tab
- addWidgets()¶
Populate tabs with widgets
- allBuiltinModels() [<class 'str'>]¶
create a list of all builtin models
- applySignal¶
- canWriteModel(model: dict = None, full_path: str | Path = '') bool¶
Determine if the current plugin can be written to file
- closeEvent(event: QEvent)¶
Overwrite the close even to assure intent
- createOrUpdateTab(filename: str | Path, widget: QWidget)¶
Check if the widget is already included in the list of tabs. Add it, if it isn’t already present otherwise update the tab.
- Parameters:
filename – A file path like object where the file displayed in the widget was loaded
widget – A QWidget to either update or add to the tabbed structure
model_str – The model text to be added to the widget object
- editorModelModified()¶
User modified the model in the Model Editor. Disable the plugin editor and show that the model is changed.
- classmethod extractFunctionBody(source_code: str, function_name: str) str¶
Extract the body of a function from a model file
- findFirstError(full_path: str | Path) int¶
Run ast and model checks Attempt to return the line number of the error if any :param full_path: full path to the model file
- generateCModel(model: dict, fname: str | Path) str¶
Generate C model from the current plugin state :param model: plugin model :param fname: filename
- generatePyModel(model: dict, fname: str | Path) str¶
generate model from the current plugin state
- getModel()¶
Retrieves plugin model from the currently open tab
- classmethod getParamHelper(param_str: str) []¶
yield a sequence of name, value pairs for the parameters in param_str
Parameters can be defined by one per line by name=value, or multiple on the same line by separating the pairs by semicolon or comma. The value is optional and defaults to “1.0”.
- includePolydisperseFuncs()¶
User has defined polydisperse parameters. Include polydisperse-only functions from model text. By default these are not included even if text exists in Form Volume Function text box.
- classmethod isWidgetInTab(tabWidget: QTabWidget, widget_to_check: QWidget) bool¶
Check to see if a widget_to_check is a tab in the tabWidget
- loadFile(filename: str | Path)¶
Performs the load operation and updates the view
- noModelCheckWarning()¶
Throw popup informing the user that no model checks will be run on a pure C model. Ask user to acknowledge and give option to not display again.
- omitPolydisperseFuncs()¶
User has no polydisperse parameters. Omit polydisperse-only functions from model text. Note that this is necessary because Form Volume Function text box does not clear its text when it disappears.
- onApply()¶
Write the plugin and update the model editor if plugin editor open Write/overwrite the plugin if model editor open
- onCancel()¶
Accept if document not modified, confirm intent otherwise.
- onHelp()¶
Bring up the Model Editor Documentation whenever the HELP button is clicked. Calls Documentation Window with the path of the location within the documentation tree (after /doc/ ….”.
- onLoad(at_launch: bool = False)¶
Loads a model plugin file. at_launch is value of whether to attempt a load of a file from launch of the widget or not
- onModifiedExit() int¶
- pluginTitleSet()¶
User modified the model name. Display the model name in the window title and allow for model save.
- populateWidgetTextBox(widget: QWidget, model_str: str)¶
Populate a widget text editor without emitting signals.
addTab() creates a fresh widget everytime it is called, so this cannot be combined with createOrUpdateTab()
- Parameters:
widget – A QWidget to either update or add to the tabbed structure
model_str – The model text to be added to the widget object
- regenerateDocumentation()¶
Defer to subprocess the documentation regeneration process
- saveClose() bool¶
Check if file needs saving before closing or model reloading
- saveOverrideWarning(filename: str | Path, model_str: str)¶
Throw popup asking user if they want to save the model despite a bad model check. Save model if user chooses to save, and do nothing if the user chooses to continue editing.
Returns True if user wanted to save file anyways, False if user wanted to continue editing without saving
- setPluginActive(is_active: bool = True)¶
Enablement control for all the controls on the simple plugin editor
- setTabEdited(is_edited: bool)¶
Change the widget name to indicate unsaved state Unsaved state: add “*” to filename display saved state: remove “*” from filename display
- staticMetaObject = PySide6.QtCore.QMetaObject("TabbedModelEditor" inherits "QDialog": Methods: #41 type=Signal, signature=applySignal() )¶
- classmethod strFromParamDict(param_dict: dict) str¶
Creates string from parameter dictionary
Example:
{ 0: ('variable','value'), 1: ('variable','value'), ... }
- updateFromEditor()¶
Save the current state of the Model Editor
- updateFromPlugin()¶
Write the plugin and update the model editor
- updateToPlugin(full_path: str | Path)¶
Update the plugin tab with new info from the model editor
- classmethod writeFile(fname: str | Path, model_str: str = '')¶
Write model content to file “fname”