hyloa.gui.script_window module

Code for manage script’s window

class hyloa.gui.script_window.LineNumberArea(editor)[source]

Bases: QWidget

A QWidget that displays line numbers for a code editor.

This widget is used to provide a visual line number area on the left.

paintEvent(event)[source]

Paint the contents of the line number area.

Parameters:

event (QPaintEvent) – The paint event containing the region to be updated.

Notes

This method delegates the painting logic to the parent code editor’s line_number_area_paint method.

sizeHint()[source]

Return the recommended size for the line number area.

Returns:

The preferred width calculated by the code editor and a height of 0.

Return type:

QSize

class hyloa.gui.script_window.PythonHighlighter(document)[source]

Bases: QSyntaxHighlighter

Class 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: QPlainTextEdit

Class 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

load_script()[source]

Function to load a pre written script

resizeEvent(event)[source]

Handle resize events and reposition the line number area accordingly.

Parameters:

event (QResizeEvent) – The event triggered when the editor is resized.

run_script()[source]

Function to run the script

save_script()[source]

Function for save the script

update_line_number_area(rect, dy)[source]

Update the display of the line number area when the editor is scrolled or updated.

Parameters:
  • rect (QRect) – The region of the editor that needs updating.

  • dy (int) – The number of pixels the view was vertically scrolled by

update_line_number_area_width(_)[source]

Update the viewport margins to account for the line number area width.

Parameters:

_ (Any) – Unused parameter, often a placeholder for a signal.