8.5.8.2.5. pymodaq_gui.utils.widgets.pattern_completer module
- class pymodaq_gui.utils.widgets.pattern_completer.PatternCompleter[source]
Bases:
objectMixin class that adds pattern completion to any text widget.
Requirements for the widget: - Must have: text(), setText(), cursorPosition() or textCursor() - Must emit: textChanged signal - Must support: keyPressEvent override
- Usage:
- class MyLineEdit(QLineEdit, PatternCompleterMixin):
- def __init__(self, parent=None):
super().__init__(parent) self.init_pattern_completer()
Methods
add_completer(pattern, completions, **kwargs)Add a completer for a specific trigger pattern.
Clean up completer resources
init_pattern_completer(**kwargs)Initialize the pattern completer system.
set_global_config(**kwargs)Update global configuration for all completers
set_visual_indicator(enabled)Enable/disable visual indicator globally
update_completer_config(pattern, **kwargs)Update configuration for a specific pattern completer.
update_completions(pattern, completions)Update completion list for a pattern
- add_completer(pattern, completions, **kwargs)[source]
Add a completer for a specific trigger pattern.
- Parameters:
pattern (
str) – Trigger string (e.g., ‘@’, ‘#’, ‘::’)completions (
list) – List of completion strings**kwargs – Per-pattern configuration (overrides global config) - visual_indicator (bool): Show visual indicator for this pattern - case_sensitive (bool): Case sensitive completion - min_width (int): Minimum popup width - max_width (int): Maximum popup width - completion_mode (str): ‘popup’ or ‘inline’ - auto_resize (bool): Auto-resize popup - word_wrap (bool): Word wrap in popup - padding (int): Extra padding for width calculation (default: 20)
- init_pattern_completer(**kwargs)[source]
Initialize the pattern completer system.
- Parameters:
**kwargs – Global configuration options - min_width (int): Minimum popup width in pixels (default: 150) - max_width (int): Maximum popup width in pixels (default: 500) - visual_indicator (bool): Enable visual indicator globally (default: False) - case_sensitive (bool): Case sensitive completion (default: False) - completion_mode (str): ‘popup’ or ‘inline’ (default: ‘popup’) - auto_resize (bool): Auto-resize popup to content (default: True) - word_wrap (bool): Enable word wrap in popup (default: False)
- class pymodaq_gui.utils.widgets.pattern_completer.PatternCompleterDelegate(*args: Any, **kwargs: Any)[source]
Bases:
QStyledItemDelegateCustom delegate for QTableWidget that uses PatternLineEdit with mixin.
- Usage:
delegate = PatternCompleterDelegate(min_width=200, max_width=600) delegate.add_completer(‘@’, [‘USA’, ‘Canada’, ‘Mexico’]) delegate.add_completer(‘#’, [‘Python’, ‘Java’, ‘C++’], case_sensitive=True) table.setItemDelegateForColumn(0, delegate)
Methods
add_completer(pattern, completions, **kwargs)Add a completer pattern for this delegate.
createEditor(parent, option, index)Create a PatternLineEdit when editing starts
destroyEditor(editor, index)Clean up editor when done
setEditorData(editor, index)Load data from model into editor
setModelData(editor, model, index)Save data from editor back to model
set_global_config(**kwargs)Update global configuration
update_completer_config(pattern, **kwargs)Update configuration for a specific pattern
update_completions(pattern, completions)Update the completion list for a specific pattern
- class pymodaq_gui.utils.widgets.pattern_completer.PatternLineEdit(*args: Any, **kwargs: Any)[source]
Bases:
QLineEdit,PatternCompleterQLineEdit with pattern completion
Methods
keyPressEvent(event)Override to handle completion keys
- class pymodaq_gui.utils.widgets.pattern_completer.PatternPlainTextEdit(*args: Any, **kwargs: Any)[source]
Bases:
QPlainTextEdit,PatternCompleterQPlainTextEdit with pattern completion
Methods
keyPressEvent(event)Override to handle completion keys
- class pymodaq_gui.utils.widgets.pattern_completer.PatternTextEdit(*args: Any, **kwargs: Any)[source]
Bases:
QTextEdit,PatternCompleterQTextEdit with pattern completion
Methods
keyPressEvent(event)Override to handle completion keys