Skip to content

Problem updating progress bar incrementally #3135

Answered by willmcgugan
mlgarrett asked this question in Q&A
Discussion options

You must be logged in to vote

Something like this:

from textual.app import App, ComposeResult
from textual.containers import Center, Middle
from textual.timer import Timer
from textual.widgets import Footer, ProgressBar
from textual import work

import time


class GUI(App[None]):
    BINDINGS = [("s", "start", "Start")]

    def compose(self) -> ComposeResult:
        with Center():
            with Middle():
                yield ProgressBar()
        yield Footer()

    def make_progress(self) -> None:
        self.query_one(ProgressBar).advance(1)

    def action_start(self) -> None:
        N = 10
        self.query_one(ProgressBar).update(total=N)
        self.process_data(N)

    @work(thread=True)
    def proc…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@willmcgugan
Comment options

@willmcgugan
Comment options

Answer selected by mlgarrett
@mlgarrett
Comment options

@mlgarrett
Comment options

@Toniolo-Marco
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants