-
Notifications
You must be signed in to change notification settings - Fork 814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New widgets being ignored #5024
Comments
Events reflected by the Textual dev console after pressing
|
Notes:
yield ProgressBar(total=100, classes='hidden') This suggests Bar's indeterminate animation somehow triggers this issue. from textual.app import App
from textual.containers import VerticalScroll
from textual.widgets import Footer, Label, RichLog
from textual.widgets._progress_bar import Bar
class MRE(App):
BINDINGS = [("z", "toggle_console", "Console")]
CSS = """
RichLog { border-top: dashed blue; height: 6; }
.hidden { display: none; }
"""
def compose(self):
yield VerticalScroll()
yield Bar(classes='hidden')
yield Footer()
yield RichLog(classes='hidden')
def on_ready(self) -> None:
self.query_one('RichLog').write('\n'.join(f'line #{i}' for i in range(5)))
def action_toggle_console(self) -> None:
self.query_one('RichLog').toggle_class('hidden')
if __name__ == '__main__':
app = MRE()
app.run() Otherly put, it has to be a ProgressBar, and it has to be in indeterminate mode. |
FWIW, it looks like the result of a race condition related to the value of self.auto_refresh. I played with that value but still have a hard time getting relevant conclusions out of it. Could this issue be a consequence of #4835? |
This change prevents a bug introduced in Textual 0.80.0 that affects the console when it becomes visible for the first time: Textualize/textual#5024
Thanks for doing the legwork. Confirmed it is something to do with auto refresh. |
Well that was fun. If a refresh (such as via auto_refresh) occurred at the point a widgets became visible, they could be missed when the layout is reflowed. Which resulted in no Resize message. |
Very interesting. Could the same thing happen when a widget becomes invisible? |
Also: how come auto_refresh induces a refresh for a hidden widget despite #4847? |
Don't forget to star the repository! Follow @textualizeio for Textual updates. |
Potentially. I may have to do something similar with hidden widgets. |
Would it translate into a rendering issue by chance? from textual.app import App
from textual.containers import VerticalScroll
from textual.widgets import Footer, ProgressBar, RichLog, Placeholder
class MRE(App):
BINDINGS = [("z", "toggle('RichLog')", "Console"), ("x", "toggle('ProgressBar')", "Progress bar")]
CSS = """
Placeholder { height: 15; }
RichLog { border-top: dashed blue; height: 6; }
.hidden { display: none; }
"""
def compose(self):
with VerticalScroll():
for i in range(10):
yield Placeholder()
yield ProgressBar(classes='hidden')
yield RichLog(classes='hidden')
yield Footer()
def on_ready(self) -> None:
self.query_one('RichLog').write('\n'.join(f'line #{i}' for i in range(5)))
def action_toggle(self, widget_type) -> None:
self.query_one(widget_type).toggle_class('hidden')
if __name__ == '__main__':
app = MRE()
app.run() |
As of Textual 0.80.0, RichLog delays actual rendering until it gets a Resize event, thus making the lack of such events visible.
This MRE showcases a seemingly nonsensical behaviour where a RichLog widget does not systematically receive Show and Resize events depending on the presence and visibility of a sibling ProgressBar widget:
Expectations
After hitting
z
, this MRE should display these lines at the bottom of the screen:Encountered behaviour
In practice, these lines:
z
multiple times (about 2 to 10 times) before showing upz Console
in the Footerhidden
)Early investigations noticed that, afer hitting
z
, Compositor.reflow() returned that no widget was hidden, no widget was shown and no widget was resized.The text was updated successfully, but these errors were encountered: