Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Rodrigo Girão Serrão <[email protected]>
  • Loading branch information
willmcgugan and rodrigogiraoserrao authored Oct 11, 2023
1 parent 6f83632 commit 2d237ff
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/guide/widgets.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ Add a rule to your CSS that targets `Tooltip`. Here's an example:

## Loading indicator

Widgets have a [`loading`][textual.widget.Widget.loading] reactive which when set to `True` will temporarily replace your widget with a [LoadingIndicator](../widgets/loading_indicator.md).
Widgets have a [`loading`][textual.widget.Widget.loading] reactive which when set to `True` will temporarily replace your widget with a [`LoadingIndicator`](../widgets/loading_indicator.md).

You can use this to indicate to the user that the app is currently working on getting data, and there will be content when that data is available.
Let's look at an example of this.
Expand Down
2 changes: 1 addition & 1 deletion src/textual/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def set_loading(self, loading: bool) -> Awaitable:
A widget in a loading state will display a LoadingIndicator that obscures the widget.
Args:
loading: `True` to put the widget in to a loading state, or `False` to reset the loading state.
loading: `True` to put the widget into a loading state, or `False` to reset the loading state.
Returns:
An optional awaitable.
Expand Down
8 changes: 8 additions & 0 deletions tests/test_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,19 @@ def compose(self) -> ComposeResult:
label = app.query_one(Label)
assert label.loading == False
assert len(label.query(LoadingIndicator)) == 0

label.loading = True
await pilot.pause()
assert len(label.query(LoadingIndicator)) == 1

label.loading = True # Setting to same value is a null-op
await pilot.pause()
assert len(label.query(LoadingIndicator)) == 1

label.loading = False
await pilot.pause()
assert len(label.query(LoadingIndicator)) == 0

label.loading = False # Setting to same value is a null-op
await pilot.pause()
assert len(label.query(LoadingIndicator)) == 0

0 comments on commit 2d237ff

Please sign in to comment.