gui.ui.tab_verse

File:

EuljiroBible/gui/ui/tab_verse.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.

Implements the gui.ui.tab_verse.TabVerse class for verse lookup, navigation, display, and output.

class gui.ui.tab_verse.TabVerse(*args, **kwargs)[source]

Bases: QWidget, TabVerseUI

GUI tab widget for Bible verse lookup, navigation, and export.

This tab allows users to select one or more Bible versions, choose a book and chapter, enter verse ranges, preview formatted output, navigate between verses, and export the currently displayed verse to the configured overlay output file.

The tab coordinates UI state, selection helpers, and backend logic components (TabVerseLogic, VerseVersionHelper, TabVerseSelectionManager, VerseOutputHandler).

tr

Translation function for UI labels and messages.

Type:

Callable[[str], str]

settings

Application-level settings dictionary.

Type:

dict

bible_data

Bible data loader instance used for verse retrieval.

Type:

BibleDataLoader

version_layout

Layout holding version selection checkboxes.

Type:

QGridLayout

version_helper

Helper for version selection and sorting.

Type:

VerseVersionHelper

selection_manager

Helper for populating and syncing book/chapter/version UI elements.

Type:

TabVerseSelectionManager

output_handler

Handler that applies formatted verse text to the main display widget and manages output formatting behavior.

Type:

VerseOutputHandler

logic

Backend verse display/export logic.

Type:

TabVerseLogic

version_list

Available Bible versions used to populate UI controls.

Type:

List[str]

current_language

Current UI language code (e.g., “ko”, “en”).

Type:

str

formatted_verse_text

Most recently formatted verse output (used for Enter key flow).

Type:

str

enter_state

Enter-key state machine (0 = ready to display, 1 = ready to export).

Type:

int

use_alias

Whether to display version aliases instead of full version names.

Type:

bool

Note

The following callables are intentionally omitted from Attributes to avoid duplicate autodoc entries, as they are already documented as class methods:

  • get_polling_status (Callable[[], bool]): Callback returning the current polling toggle state.

  • get_always_show_setting (Callable[[], bool]): Callback returning the current “always show buttons” toggle state.

__init__(version_list, settings, tr, get_polling_status=None, get_always_show_setting=None)[source]

Initialize the TabVerse UI and connect backend helpers.

This creates Bible data access, builds the version selection UI, initializes selection helpers and logic handlers, and installs UI signal connections for resetting Enter-state behavior when inputs change.

Parameters:
  • version_list (List[str]) – Available Bible version identifiers.

  • settings (dict) – Loaded application settings.

  • tr (Callable[[str], str]) – Translation function for UI labels.

  • get_polling_status (Callable[[], bool] | None) – Optional callback that returns whether polling is active.

  • get_always_show_setting (Callable[[], bool] | None) – Optional callback that returns whether export/clear buttons should always be shown.

change_language(lang_code)[source]

Update UI labels and state to reflect a new language setting.

This updates visible text, version summary rendering, book dropdown population, and button labels.

Parameters:

lang_code (str) – Language code (e.g., “ko”, “en”).

resizeEvent(event)[source]

Handle resize events and recompute the version checkbox grid layout.

Parameters:

event (QResizeEvent) – Resize event object.

update_button_layout()[source]

Update the action button layout depending on effective polling state.

Effective polling is defined as: polling enabled OR the “always show buttons” setting enabled.

get_polling_status()[source]

Return the current polling toggle state.

This method is designed to be overridden or replaced by an injected callback.

Returns:

True if polling is enabled; otherwise False.

Return type:

bool

get_always_show_setting()[source]

Return the current “always show buttons” setting.

This method is designed to be overridden or replaced by an injected callback.

Returns:

True if export/clear buttons should always be visible; otherwise False.

Return type:

bool

toggle_alias_mode()[source]

Toggle between alias names and full names for Bible version display.

This updates the alias mode flag, refreshes the toggle label, and updates the version summary accordingly.

handle_enter()[source]

Handle Enter-key behavior as a two-step flow: display then export.

If no formatted verse is currently staged, this displays the verse and caches the formatted output. If a formatted verse is already staged, this exports it to the output destination and resets the state machine.

get_reference()[source]

Build and return the resolved verse reference tuple from current UI inputs.

Returns:

(versions, book, chapter, (start_verse, end_verse)) as produced by

the shared reference resolver.

Return type:

tuple

apply_output_text(text)[source]

Apply formatted verse output text to the main display.

Parameters:

text (str) – Formatted text to display.

shift_verse(delta)[source]

Shift the current verse number by a delta and refresh the displayed output.

Parameters:

delta (int) – +1 for next verse, -1 for previous verse.

reset_enter_state()[source]

Reset Enter-key state to the default “ready to display” mode.

This clears any staged formatted verse output so the next Enter press performs a display operation.

clear_outputs()[source]

Clear the verse display and clear the output destination.

This clears the UI display widget and writes an empty string to the configured output file(s) to stop any active overlay display.