Repository navigation
Progress
The box Turbo Pascal showed while compiling, for anything that takes a while (turboframe.ui.progress).
| Use it for | a job the user waits for, and may stop: a build, a fetch, an import |
| Import | from turboframe.ui.progress import ProgressDialog, run_with_progress, bar_text |
| Needs | nothing beyond TurboFrame |
| Extend | your rows, your verdict; AUTO_CLOSE, AUTO_CLOSE_PROBLEMS
|

It has rows (File: shop.py), a clock, and a bar in Norton Commander's style, in CP437 blocks. The bar fills while the job says how far it is; when the job cannot say, a block goes back and forth. At the bottom it tells you what to do: Esc stops the job while it runs; then the verdict ("Success", "Errors") and any key closes it. The box also closes by itself, after 2 seconds for a success or 5 for a problem (AUTO_CLOSE, AUTO_CLOSE_PROBLEMS).
from textual import work
from turboframe.ui.progress import ProgressDialog, run_with_progress
@work # a method of your DesktopApp
async def build(self) -> None:
dialog = ProgressDialog("Build", [("Target", "")])
async def job() -> int:
for n, target in enumerate(targets):
dialog.set("Target", target)
await compile_one(target)
dialog.progress((n + 1) / len(targets))
return len(targets)
done = await run_with_progress(self, dialog, job(), lambda n: ("Success", True, [("Built", str(n))]))
if done is None:
self.hint("stopped")-
run_with_progress(app, dialog, job, verdict)returns the job's result as soon as it ends, orNonewhen it was stopped with Esc, which cancels the job's task. An exception of the job closes the box and propagates. -
verdict(result)gives(word, ok, rows): the word to show, whether it went well, and the final rows. -
ProgressDialog(title, rows, width=52, stoppable=True):stoppable=Falsefor a job that cannot be stopped. -
dialog.set(label, value)changes or adds a row;dialog.progress(fraction)fills the bar (None: it cannot say). -
bar_text(width, fraction=None)draws the bar alone, as RichText, for a status line. The language server's indexing uses it there (see The Editor).
Use a with app.busy("Indexing"): spinner in the status line instead for work the user does not wait for (see The Desktop). The Git menu's Pull, Push and Fetch run under this box (Git and Diffs); a command's output can go to a log meanwhile (Log and Output Windows).
The box ends filled whatever the verdict: the bar says how far the job got, the verdict how it went. Only a stopped job leaves it where it was.

API: turboframe.ui.progress.
TurboFrame · part of Divengine · GPL-3.0-or-later · report an issue
Tutorial
Examples
The desktop
- The Desktop
- Application Mixins
- Windows and Lists
- Dialogs
- Histories
- Progress
- Themes and Colors
- Glyphs
- Settings and Recent Files
- Command Palette
Editing
Tasks
Languages
Running
Reference
Links