• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

popstas / talks-reducer / 22706774772

05 Mar 2026 07:15AM UTC coverage: 67.445% (-0.1%) from 67.543%
22706774772

push

github

popstas
feat(gui): wire up progress bar during FFmpeg encoding

Forward total frame count and a progress_callback through
_TkProgressReporter → _GuiProgressHandle so that progress.advance()
calls in ffmpeg.py drive the GUI progress bar at 1% granularity
(mapped into the 5–100% range, since audio occupies 0–5%).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

8 of 17 new or added lines in 1 file covered. (47.06%)

198 existing lines in 2 files now uncovered.

6124 of 9080 relevant lines covered (67.44%)

0.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.26
/talks_reducer/gui/progress.py
1
"""Progress helpers that bridge the pipeline with the Tkinter GUI."""
2

3
from __future__ import annotations
1✔
4

5
from typing import Callable, Optional
1✔
6

7
from ..progress import CallbackProgressHandle, ProgressHandle, SignalProgressReporter
1✔
8

9

10
class _GuiProgressHandle(CallbackProgressHandle):
1✔
11
    """Simple progress handle that records totals but only logs milestones."""
12

13
    def __init__(
1✔
14
        self,
15
        log_callback: Callable[[str], None],
16
        desc: str,
17
        *,
18
        total: Optional[int] = None,
19
        progress_callback: Optional[Callable[[float], None]] = None,
20
        audio_weight: float = 5.0,
21
    ) -> None:
22
        self._log_callback = log_callback
1✔
23
        self._progress_callback = progress_callback
1✔
24
        self._audio_weight = audio_weight
1✔
25
        self._last_reported_percent = -1
1✔
26
        super().__init__(
1✔
27
            desc=desc,
28
            total=total,
29
            on_start=self._on_start,
30
            on_update=self._on_update if progress_callback else None,
31
            on_finish=self._on_finish,
32
        )
33

34
    def _on_start(self, desc: str, total: Optional[int]) -> None:
1✔
35
        del total
1✔
36
        if desc:
1✔
37
            self._log_callback(f"{desc} started")
1✔
38

39
    def _on_update(self, current: int, total: Optional[int], desc: str) -> None:
1✔
NEW
40
        del desc
×
NEW
41
        if self._progress_callback is None or not total or total <= 0:
×
NEW
42
            return
×
NEW
43
        percent = min(int(current * 100 / total), 100)
×
NEW
44
        if percent == self._last_reported_percent:
×
NEW
45
            return
×
NEW
46
        self._last_reported_percent = percent
×
NEW
47
        bar_value = self._audio_weight + (percent / 100.0) * (
×
48
            100.0 - self._audio_weight
49
        )
NEW
50
        self._progress_callback(bar_value)
×
51

52
    def _on_finish(self, current: int, total: Optional[int], desc: str) -> None:
1✔
53
        del current, total
1✔
54
        if desc:
1✔
55
            self._log_callback(f"{desc} completed")
1✔
56

57

58
class _TkProgressReporter(SignalProgressReporter):
1✔
59
    """Progress reporter that forwards updates to the GUI thread."""
60

61
    def __init__(
1✔
62
        self,
63
        log_callback: Callable[[str], None],
64
        process_callback: Optional[Callable] = None,
65
        *,
66
        stop_callback: Optional[Callable[[], bool]] = None,
67
        progress_callback: Optional[Callable[[float], None]] = None,
68
    ) -> None:
69
        super().__init__()
1✔
70
        self._log_callback = log_callback
1✔
71
        self.process_callback = process_callback
1✔
72
        self._stop_callback = stop_callback
1✔
73
        self._progress_callback = progress_callback
1✔
74

75
    def log(self, message: str) -> None:
1✔
76
        self._log_callback(message)
1✔
77
        print(message, flush=True)
1✔
78

79
    def task(
1✔
80
        self, *, desc: str = "", total: Optional[int] = None, unit: str = ""
81
    ) -> _GuiProgressHandle:
82
        del unit
1✔
83
        return _GuiProgressHandle(
1✔
84
            self._log_callback,
85
            desc,
86
            total=total,
87
            progress_callback=self._progress_callback,
88
        )
89

90
    def stop_requested(self) -> bool:
1✔
91
        """Return ``True`` when the GUI has asked to cancel processing."""
92

93
        if self._stop_callback is None:
1✔
94
            return False
×
95
        return bool(self._stop_callback())
1✔
96

97

98
__all__ = ["_GuiProgressHandle", "_TkProgressReporter"]
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc