-
-
Notifications
You must be signed in to change notification settings - Fork 999
Description
Looking at closed issues it looks like this has come up before: #3516 - This suggests it was possibly resolved, but I am definitely seeing it on the current version (0.86.3
).
Widgets remain interactable when set to loading.
from textual import on
from textual.app import App, ComposeResult
from textual.containers import Container
from textual.widgets import Button, Footer
class ButtonApp(App):
BINDINGS = [
("c", "loading('c')", "Toggle Container"),
("b", "loading('b')", "Toggle Button")
]
def compose(self) -> ComposeResult:
yield Footer()
with Container():
yield Button("Kick me")
@on(Button.Pressed)
def pressed(self):
self.notify("Ouch!")
def action_loading(self, item: str):
widget = self.query_one(Container if item == "c" else Button)
widget.loading = not widget.loading
if __name__ == '__main__':
ButtonApp().run()
In this example you can toggle loading on the button or container using bindings. Normally, the button can be interacted with by mouse or keyboard. If you toggle loading on for the container, the button can be interacted with still via keyboard, but not by mouse.
If you toggle loading on the button, it can be clicked on with the mouse, but not pressed using the keyboard.
It feels to me that if the toggle loading feature is there, the widget should be fully disabled when loading is set. The current wording of the docs also supports this I believe:
"If set to True this widget will temporarily be replaced with a loading indicator." - Replaced suggests the widget is not present while loading is set to True.