gui.ui.common

File:

EuljiroBible/gui/ui/common.py

Author:

Benjamin Jaedon Choi - https://github.com/saintbenjamin

Affiliated Church:

The Eulji-ro Presbyterian Church [대한예수교장로회(통합) 을지로교회]

Address:

The Eulji-ro Presbyterian Church, 24-10, Eulji-ro 20-gil, Jung-gu, Seoul 04549, South Korea

Telephone:

+82-2-2266-3070

E-mail:

euljirochurch [at] G.M.A.I.L. (replace [at] with @ and G.M.A.I.L as you understood.)

License:

MIT License with Attribution Requirement (see LICENSE file for details); Copyright (c) 2025 The Eulji-ro Presbyterian Church.

Provides reusable UI widgets such as buttons, checkboxes, and loading indicator. Includes utility wrappers for QPushButton creation with SVG icons and dynamic sizing.

gui.ui.common.create_button(text, callback=None)[source]

Creates a QPushButton with optional click callback.

Parameters:
  • text (str) – Text to display on the button.

  • callback (function, optional) – Slot to connect to clicked() signal.

Returns:

The configured button.

Return type:

QPushButton

gui.ui.common.create_checkbox(text, checked=False, callback=None)[source]

Creates a QCheckBox with optional initial state and signal connection.

Parameters:
  • text (str) – Label text next to the checkbox.

  • checked (bool) – Whether the checkbox is initially checked.

  • callback (function, optional) – Slot for stateChanged signal.

Returns:

The configured checkbox.

Return type:

QCheckBox

gui.ui.common.create_svg_text_button(svg_path, text, icon_size=20, tooltip='', callback=None)[source]

Creates a QPushButton with SVG icon and text.

Parameters:
  • svg_path (str) – Path to SVG icon.

  • text (str) – Button label.

  • icon_size (int) – Icon size in pixels (default: 20).

  • tooltip (str) – Tooltip text.

  • callback (function, optional) – Slot for clicked() signal.

Returns:

The configured icon + text button.

Return type:

QPushButton

class gui.ui.common.LoadingIndicator(*args, **kwargs)[source]

Bases: QWidget

A spinning arc-based loading indicator widget.

This widget displays a rotating arc animation to indicate that a background operation (such as data loading or initialization) is in progress. It is designed to be lightweight and self-contained, relying on a QTimer-driven angle update and custom painting via QPainter.

The widget automatically centers itself within its parent when shown or when the parent is resized.

angle

Current rotation angle of the arc, in degrees. This value is incremented periodically by the internal timer to animate the spinner.

Type:

int

timer

Timer used to update the rotation angle at a fixed interval, driving the animation loop.

Type:

QTimer

__init__(parent=None)[source]

Initializes the spinning loader.

Parameters:

parent (QWidget, optional) – Parent widget. Defaults to None.

start()[source]

Starts the loading animation.

stop()[source]

Stops the animation and hides the widget.

update_angle()[source]

Advances the angle for the rotating arc.

paintEvent(event)[source]

Paints the spinning arc using QPainter.

Parameters:

event (QPaintEvent) – Internal paint event.

showEvent(event)[source]

Centers the widget within its parent on show.

Parameters:

event (QShowEvent) – Widget shown.

resizeEvent(event)[source]

Keeps widget centered when parent resizes.

Parameters:

event (QResizeEvent) – Resize trigger.