nomad_camels.ui_widgets package
Submodules
nomad_camels.ui_widgets.add_remove_table module
- class nomad_camels.ui_widgets.add_remove_table.AddRemoveDialoge(addLabel='+', removeLabel='-', horizontal=True, editables=None, checkables=(), headerLabels=None, orderBy=None, parent=None, tableData=None, title='', comboBoxes=None, subtables=None, checkstrings=None, check_duplicates=None, askdelete=False, default_values=None, check_string_function=None)
Bases:
QDialog
A QDialog providing an AddRemoveTable.
- accept()
Overwrites the accept method of the QDialog to check for integrity of the data before accepting the dialog.
- get_data()
- keyPressEvent(a0: QKeyEvent) None
Overwrites the keyPressEvent of the QDialog so that it does not close when pressing Enter/Return.
- Parameters:
a0 (QKeyEvent :)
- staticMetaObject = PySide6.QtCore.QMetaObject("AddRemoveDialoge" inherits "QDialog": )
- class nomad_camels.ui_widgets.add_remove_table.AddRemoveTable(addLabel='+', removeLabel='-', horizontal=True, editables=None, checkables=(), headerLabels=None, orderBy=None, parent=None, tableData=None, title='', comboBoxes=None, subtables=None, growsize=False, checkstrings=None, check_duplicates=None, askdelete=False, fixedsize=False, enableds=None, default_values=None, add_tooltip=None, remove_tooltip=None, check_string_function=None)
Bases:
QWidget
This widget provides a QTableView and two buttons for adding / removing rows / columns.
- add(vals=None, change_focus=False)
Add the vals to the table as a new line. Checks are done for each part, whether there should be a comboBox etc.
- Parameters:
vals – (Default value = None)
- added
- append_variable(val)
Used for the single actions of the context menu.
- Parameters:
val
- change_table_data(tableData, change_focus=False)
- Parameters:
tableData
- check_for_duplicates()
Check for duplicates and highlight them in red and raise an error.
- check_selection()
- check_string(item)
If an element is part of the checkstrings, the item becomes green if valid, red otherwise and white if empty.
- Parameters:
item
Generates the right-click-menu. There are entries for inserting (replace) and appending the variables, channels, functions and operators.
- Parameters:
pos
- filter_actions(query)
- insert_variable(val)
Used for the single actions of the context menu.
- Parameters:
val
- load_table_data(change_focus=False)
Putting the tableData into the table.
- remove()
- removed
- sizechange
- staticMetaObject = PySide6.QtCore.QMetaObject("AddRemoveTable" inherits "QWidget": Methods: #33 type=Signal, signature=sizechange() #34 type=Signal, signature=added(int), parameters=int #35 type=Signal, signature=removed(int), parameters=int )
- update_max_hight()
- update_table_data()
Reading all the data of the table, putting it as dict into self.tableData and returning it.
- class nomad_camels.ui_widgets.add_remove_table.MultiTableDialog(table_args=[], parent=None, title='')
Bases:
QDialog
A QDialog providing an AddRemoveTable.
- get_data()
- hide_add_remove_buttons()
- keyPressEvent(a0: QKeyEvent) None
Overwrites the keyPressEvent of the QDialog so that it does not close when pressing Enter/Return.
- Parameters:
a0 (QKeyEvent :)
- staticMetaObject = PySide6.QtCore.QMetaObject("MultiTableDialog" inherits "QDialog": )
nomad_camels.ui_widgets.channels_check_table module
- class nomad_camels.ui_widgets.channels_check_table.Call_Functions_Table(parent=None, headerLabels=None, info_dict=None, title='', functions=None)
Bases:
QWidget
- build_table()
- change_search()
- check_change(pos)
- get_info()
- staticMetaObject = PySide6.QtCore.QMetaObject("Call_Functions_Table" inherits "QWidget": )
- update_info()
- class nomad_camels.ui_widgets.channels_check_table.Channels_Check_Table(parent, headerLabels=None, only_output=False, info_dict=None, checkstrings=None, title='', channels=None, use_configs=False, checkables=None, use_aliases=True)
Bases:
QWidget
- append_variable(val)
Used for the single actions of the context menu.
- Parameters:
val
- build_channels_table()
- change_search()
- check_change(pos)
- Parameters:
pos
- check_string(item)
If an element is part of the checkstrings, the item becomes green if valid, red otherwise and white if empty.
- Parameters:
item
Generates the right-click-menu. There are entries for inserting (replace) and appending the variables, channels, functions and operators.
- Parameters:
pos
- filter_actions(query)
- get_info()
- insert_variable(val)
Used for the single actions of the context menu.
- Parameters:
val
- staticMetaObject = PySide6.QtCore.QMetaObject("Channels_Check_Table" inherits "QWidget": )
- update_info()
- class nomad_camels.ui_widgets.channels_check_table.CheckableTableWidgetItem(checkState=CheckState.Unchecked)
Bases:
QTableWidgetItem
nomad_camels.ui_widgets.console_redirect module
- class nomad_camels.ui_widgets.console_redirect.Console_TextEdit(parent, max_lines=10000)
Bases:
QTextEdit
- append(text)
Ensure the number of lines does not exceed self.max_lines.
- staticMetaObject = PySide6.QtCore.QMetaObject("Console_TextEdit" inherits "QTextEdit": )
- write_error(text)
- write_output(text)
- class nomad_camels.ui_widgets.console_redirect.Error_Writer(text_signal_handler, use_old_stderr=False)
Bases:
StringIO
- write(*args, **kwargs)
- Parameters:
*args
**kwargs
- class nomad_camels.ui_widgets.console_redirect.TextSignalHanlder
Bases:
QWidget
- staticMetaObject = PySide6.QtCore.QMetaObject("TextSignalHanlder" inherits "QWidget": Methods: #33 type=Signal, signature=write_error_signal(QString), parameters=QString #34 type=Signal, signature=write_output_signal(QString), parameters=QString )
- write_error_signal
- write_output_signal
nomad_camels.ui_widgets.drag_drop_tree_view module
- class nomad_camels.ui_widgets.drag_drop_tree_view.Drag_Drop_TreeView
Bases:
QTreeView
This Class is used for the protocol sequence. Most importantly it emits the dragdrop signal when something is dragged / dropped.
- del_clicked
- dragdrop
- dropEvent(self, event: PySide6.QtGui.QDropEvent, /) None
- keyPressEvent(self, event: PySide6.QtGui.QKeyEvent, /) None
- paintEvent(self, event: PySide6.QtGui.QPaintEvent, /) None
- startDrag(self, supportedActions: PySide6.QtCore.Qt.DropAction, /) None
- staticMetaObject = PySide6.QtCore.QMetaObject("Drag_Drop_TreeView" inherits "QTreeView": Methods: #88 type=Signal, signature=dragdrop() #89 type=Signal, signature=del_clicked() )
nomad_camels.ui_widgets.run_queue module
- class nomad_camels.ui_widgets.run_queue.RunQueue(parent=None, protocols_dict=None, variable_table=None)
Bases:
QListWidget
A QListWidget that represents the run queue. It contains a list of RunWidgets, each representing a single run in the queue. When a run is removed from the queue, the corresponding RunWidget is removed from the QListWidget. The order of the runs in the queue is determined by the order of the RunWidgets in the QListWidget. The RunQueue emits a signal when a the ready status of a run is changed, so that the next run can be started automatically.
Each run can have its own variables, the values do not change the default settings for the protocol.
- add_item(text, api_uuid=None)
Add a new item to the run queue. The item is represented by a RunWidget, which is added to a QListWidgetItem, which is then added to the QListWidget. The item is also added to the order list, which determines the order of the runs in the queue. The name of the protocol and its variables are stored in the protocol_name_variables dictionary.
- change_variable_table()
Change the variables displayed in the variable table to match the selected run.
- check_checkbox(name)
Check the checkbox of the specified item.
- Parameters:
name (str)
check. (string of the QListWidgetItem. The item to)
- check_next_protocol()
Check if the first protocol in the queue is ready to run. If it is, emit the protocol_signal with the name of the protocol and its variables. If the protocol is not ready to run, do nothing.
- Returns:
True if the next protocol is ready to run, False otherwise.
- Return type:
bool
- paintEvent(self, e: PySide6.QtGui.QPaintEvent, /) None
- protocol_signal
- remove_first()
Remove the first item in the queue.
- remove_item(item, ask=True)
Remove an item from the run queue. The item is removed from the order list and the QListWidget. If ask is True, a QMessageBox is shown to ask the user if they are sure they want to remove the item.
- Parameters:
item (QListWidgetItem) – The item to remove.
ask (bool, optional) – Whether to ask the user if they are sure they want to remove the item. The default is True.
- remove_item_by_name(name)
Remove an item from the run queue by name.
- Parameters:
name (str) – The name of the item to remove.
- staticMetaObject = PySide6.QtCore.QMetaObject("RunQueue" inherits "QListWidget": Methods: #83 type=Signal, signature=protocol_signal(QString,QVariantMap,QString), parameters=QString, QVariantMap, QString )
- update_order_list()
Update the order list to match the current order of items in the QListWidget
- update_variables_queue(name, variables, index)
Update the variables for a protocol in the queue.
- Parameters:
name (str) – The name of the protocol.
variables (dict) – The new variables for the protocol.
- class nomad_camels.ui_widgets.run_queue.RunWidget(text)
Bases:
QWidget
A widget that represents a single run in the run queue. It contains a label with the name of the protocol, a checkbox whether the protocol is ready to run, and a button to remove the protocol from the queue.
- Parameters:
text (str) – The name of the protocol / the text to display on the label.
- staticMetaObject = PySide6.QtCore.QMetaObject("RunWidget" inherits "QWidget": )
nomad_camels.ui_widgets.toast_notification module
Toast Notification System for NOMAD CAMELS
This module provides an elegant toast notification system based on QMessageBox for better user experience. It includes both toast notifications and enhanced error handling capabilities.
Features: - Toast notifications with different types (info, warning, error, success) - Auto-dismiss functionality - Non-blocking notifications - Enhanced error handling with toast integration - Elegant UI using native QMessageBox styling - Modular design for easy integration
- class nomad_camels.ui_widgets.toast_notification.EnhancedErrorHandler(toast_manager: ToastManager, parent: QWidget | None = None)
Bases:
object
Enhanced error handler that provides better user experience for errors.
This class provides methods to handle errors gracefully with toast notifications instead of raising exceptions or showing blocking dialogs.
- handle_general_error(error: Exception, context: str = '', show_dialog: bool = False, log_error: bool = True) None
Handle general errors with toast notification.
- Parameters:
error – The exception that occurred
context – Additional context about where the error occurred
show_dialog – Whether to also show a dialog
log_error – Whether to log the error
- handle_validation_error(error_message: str, title: str = 'Validation Error', show_dialog: bool = False, log_error: bool = True) bool
Handle validation errors with toast notification.
- Parameters:
error_message – The error message to display
title – Title for the notification
show_dialog – Whether to also show a dialog
log_error – Whether to log the error
- Returns:
False to indicate validation failure
- class nomad_camels.ui_widgets.toast_notification.ToastConfig(duration: int = 5000, position: str = 'top-right', auto_dismiss: bool = True, show_icon: bool = True, stack_notifications: bool = True, max_stack_count: int = 5)
Bases:
object
Configuration class for toast notifications.
- auto_dismiss: bool = True
- duration: int = 5000
- max_stack_count: int = 5
- position: str = 'top-right'
- show_icon: bool = True
- stack_notifications: bool = True
- class nomad_camels.ui_widgets.toast_notification.ToastManager(parent: QWidget | None = None)
Bases:
QObject
Manager class for handling multiple toast notifications.
This class manages the display, stacking, and lifecycle of toast notifications throughout the application.
- dismiss_all()
Dismiss all active toast notifications.
- dismiss_toast(toast_id: int)
Dismiss a specific toast notification.
- eventFilter(obj, event)
Filter events to handle window resize.
- show_toast(message: str, title: str = '', toast_type: ToastType = ToastType.INFO, config: ToastConfig | None = None, callback: Callable | None = None) int
Show a toast notification.
- Parameters:
message – The message to display
title – Optional title
toast_type – Type of notification
config – Optional configuration
callback – Optional callback function
- Returns:
The toast ID for later reference
- staticMetaObject = PySide6.QtCore.QMetaObject("ToastManager" inherits "QObject": )
- class nomad_camels.ui_widgets.toast_notification.ToastMessageBox(message: str, title: str = '', toast_type: ToastType = ToastType.INFO, config: ToastConfig | None = None, parent: QWidget | None = None, callback: Callable | None = None)
Bases:
QMessageBox
A toast notification widget based on QMessageBox for elegant UI.
This widget provides a modern, non-blocking notification system that uses the native QMessageBox styling for consistency and elegance.
- clicked
- dismiss()
Dismiss the notification.
- dismissed
- eventFilter(obj, event)
Filter events to handle window resize.
- show_notification()
Show the notification with proper positioning.
- staticMetaObject = PySide6.QtCore.QMetaObject("ToastMessageBox" inherits "QMessageBox": Methods: #42 type=Signal, signature=dismissed() #43 type=Signal, signature=clicked() )
- class nomad_camels.ui_widgets.toast_notification.ToastType(value)
Bases:
Enum
Enumeration for different types of toast notifications.
- ERROR = 'error'
- INFO = 'info'
- SUCCESS = 'success'
- WARNING = 'warning'
- nomad_camels.ui_widgets.toast_notification.get_error_handler(parent: QWidget | None = None) EnhancedErrorHandler
Get the global error handler instance.
- Parameters:
parent – Parent widget for the error handler
- Returns:
The global error handler instance
- nomad_camels.ui_widgets.toast_notification.get_toast_manager(parent: QWidget | None = None) ToastManager
Get the global toast manager instance.
- Parameters:
parent – Parent widget for the toast manager
- Returns:
The global toast manager instance
- nomad_camels.ui_widgets.toast_notification.handle_general_error(error: Exception, context: str = '', show_dialog: bool = False, parent: QWidget | None = None) None
Convenience function to handle general errors.
- Parameters:
error – The exception that occurred
context – Additional context
show_dialog – Whether to also show a dialog
parent – Parent widget
- nomad_camels.ui_widgets.toast_notification.handle_validation_error(error_message: str, title: str = 'Validation Error', show_dialog: bool = False, parent: QWidget | None = None) bool
Convenience function to handle validation errors.
- Parameters:
error_message – The error message
title – Title for the notification
show_dialog – Whether to also show a dialog
parent – Parent widget
- Returns:
False to indicate validation failure
- nomad_camels.ui_widgets.toast_notification.show_error_toast(message: str, title: str = 'Error', config: ToastConfig | None = None, callback: Callable | None = None, parent: QWidget | None = None) int
Convenience function to show an error toast notification.
- Parameters:
message – The error message to display
title – Optional title (defaults to “Error”)
config – Optional configuration
callback – Optional callback function
parent – Parent widget
- Returns:
The toast ID
- nomad_camels.ui_widgets.toast_notification.show_info_toast(message: str, title: str = 'Information', config: ToastConfig | None = None, callback: Callable | None = None, parent: QWidget | None = None) int
Convenience function to show an info toast notification.
- Parameters:
message – The info message to display
title – Optional title (defaults to “Information”)
config – Optional configuration
callback – Optional callback function
parent – Parent widget
- Returns:
The toast ID
- nomad_camels.ui_widgets.toast_notification.show_success_toast(message: str, title: str = 'Success', config: ToastConfig | None = None, callback: Callable | None = None, parent: QWidget | None = None) int
Convenience function to show a success toast notification.
- Parameters:
message – The success message to display
title – Optional title (defaults to “Success”)
config – Optional configuration
callback – Optional callback function
parent – Parent widget
- Returns:
The toast ID
- nomad_camels.ui_widgets.toast_notification.show_toast(message: str, title: str = '', toast_type: ToastType = ToastType.INFO, config: ToastConfig | None = None, callback: Callable | None = None, parent: QWidget | None = None) int
Convenience function to show a toast notification.
- Parameters:
message – The message to display
title – Optional title
toast_type – Type of notification
config – Optional configuration
callback – Optional callback function
parent – Parent widget
- Returns:
The toast ID
- nomad_camels.ui_widgets.toast_notification.show_warning_toast(message: str, title: str = 'Warning', config: ToastConfig | None = None, callback: Callable | None = None, parent: QWidget | None = None) int
Convenience function to show a warning toast notification.
- Parameters:
message – The warning message to display
title – Optional title (defaults to “Warning”)
config – Optional configuration
callback – Optional callback function
parent – Parent widget
- Returns:
The toast ID
nomad_camels.ui_widgets.variable_table module
- class nomad_camels.ui_widgets.variable_table.VariableBox(parent=None, protocol=None, editable_names=True, variables=None, name='')
Bases:
QWidget
- closeEvent(self, event: PySide6.QtGui.QCloseEvent, /) None
- closing
- new_values_signal
- staticMetaObject = PySide6.QtCore.QMetaObject("VariableBox" inherits "QWidget": Methods: #33 type=Signal, signature=new_values_signal(QVariantMap), parameters=QVariantMap #34 type=Signal, signature=closing() )
- update_values()
- class nomad_camels.ui_widgets.variable_table.VariableTable(parent=None, protocol=None, editable_names=True, variables=None)
Bases:
QTableView
- append_variable(name='name', value='value', unique=True)
- check_variable()
- clear()
- get_unique_name(name='name')
- paintEvent(self, e: PySide6.QtGui.QPaintEvent, /) None
- set_protocol(protocol)
- staticMetaObject = PySide6.QtCore.QMetaObject("VariableTable" inherits "QTableView": )
- update_variables()
nomad_camels.ui_widgets.variable_tool_tip_box module
- class nomad_camels.ui_widgets.variable_tool_tip_box.Variable_Box(parent=None, check_function=None, provide_context_menu=True, make_green=True)
Bases:
QLineEdit
QLineEdit that checks its contents for validity and then color- codes the background.
- append_variable(variable)
Used for the single actions of the context menu.
- Parameters:
variable
- check_string()
Check the string and then set the corresponding background-color.
Generates the right-click-menu. There are entries for inserting (replace) and appending the variables, channels, functions and operators.
- Parameters:
pos
- filter_actions(query)
- get_value()
- insert_variable(variable)
Used for the single actions of the context menu.
- Parameters:
variable
- setEnabled(a0: bool) None
- Parameters:
a0 (bool :)
- set_check_function(check_function, make_green=False, tooltip=None, provide_context_menu=False)
Set the check function for the variable box.
- Parameters:
check_function (callable) – The function to use for checking the validity of the input.
make_green (bool, optional) – If True, the background will be set to green if the input is valid.
tooltip (str, optional) – The tooltip text to display when hovering over the box.
provide_context_menu (bool, optional) – If False, the context menu with variables and channels will be suppressed.
- Return type:
None
- staticMetaObject = PySide6.QtCore.QMetaObject("Variable_Box" inherits "QLineEdit": )
- nomad_camels.ui_widgets.variable_tool_tip_box.check_no_special_characters(string)
Check if string is free of special characters.
- Parameters:
string (str) – The string to check.
- Returns:
True if the string is valid (no special characters), False otherwise.
- Return type:
bool