hyloa.gui.script_window module
Code for manage script’s window
- class hyloa.gui.script_window.LineNumberArea(editor)[source]
Bases:
QWidgetA QWidget that displays line numbers for a code editor.
This widget is used to provide a visual line number area on the left.
- class hyloa.gui.script_window.PythonHighlighter(document)[source]
Bases:
QSyntaxHighlighterClass to adorn script window with highliter
- highlightBlock(text)[source]
Applies syntax highlighting to a single block of text.
This method highlights all matching patterns defined in self.highlighting_rules as well as multi-line string blocks (e.g., delimited by triple single or double quotes). It is intended to be called automatically by the QSyntaxHighlighter for each block of text.
- Parameters:
text (str) – The block of text to be highlighted.
- highlight_multiline(text, start_expr, end_expr, format)[source]
Applies formatting to multi-line text sections matching given delimiters.
Highlights text between start_expr and end_expr, which can span multiple blocks (e.g., for triple-quoted strings). If the end delimiter is not found in the current block, the state is set to continue highlighting in the next block.
- Parameters:
text (str) – The current block of text to search for multi-line expressions.
start_expr (QRegExp) – Regular expression defining the start of the multi-line section.
end_expr (QRegExp) – Regular expression defining the end of the multi-line section.
format (QTextCharFormat) – The text format to apply to the matched multi-line section.
- class hyloa.gui.script_window.ScriptEditor(app_instance)[source]
Bases:
QPlainTextEditClass to handle the scripting window
- highlight_current_line()[source]
Highlight the background of the current line where the cursor is.
The color automatically adapts to the current palette, choosing a light or dark translucent shade depending on whether the application is using a light or dark theme.
- line_number_area_paint(event)[source]
Paint the line number area.
- Parameters:
event (QPaintEvent) – The paint event containing the area to be redrawn.
Notes
This method paints line numbers aligned to the right of the line number area, highlighting only visible blocks.
- line_number_area_width()[source]
Calculate the width required for the line number area.
- Returns:
space – The width in pixels needed to display the line numbers based on the current number of text blocks (lines).
- Return type:
int
- resizeEvent(event)[source]
Handle resize events and reposition the line number area accordingly.
- Parameters:
event (QResizeEvent) – The event triggered when the editor is resized.