scroll_end off by one
See original GitHub issueIt looks like Widget.scroll_end()
is off by one line. Here’s an app to reproduce:
from textual.app import App, ComposeResult
from textual.widgets import DataTable, Footer
class Test(App):
BINDINGS = [("a", "add_row", "Add a row")]
DEFAULT_CSS = """
DataTable {
height: 5;
}
"""
def compose(self) -> ComposeResult:
rows = (
("1", "one"),
("2", "two"),
("3", "three"),
("4", "four"),
("5", "five"),
)
self.table = DataTable()
self.table.add_columns("#", "number")
self.table.add_rows(rows)
yield self.table
yield Footer()
def action_add_row(self) -> None:
self.table.add_row("6", "six")
self.table.scroll_end()
Test().run()
After adding the sixth row, the DataTable
scrolls to the fifth row.
Issue Analytics
- State:
- Created 10 months ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
How do you turn off synchronous scrolling?
I'm a writer. I use Word 2010. I want to work on two different Word documents while they're displayed on one screen.
Read more >View Side by Side in Word - Instructions and Video Lesson
To turn off synchronous scrolling, click the button again. Instructions on How to Change Window Sizes When Comparing Two Documents in Word. To ......
Read more >[TUTORIAL] How to VIEW 2 Word Docs SIDE-BY ... - YouTube
In one of the documents, click the View tab. 3. In the "Window" section, click on "View Side by Side To turn off...
Read more >Turning Off Synchronous Scrolling - Excel Ribbon Tips
You can turn it off, on a case-by-case basis, by simply displaying the View tab of the ribbon and then clicking the Synchronous...
Read more >disable scrolling on specific page - css - Stack Overflow
Is there any way to disable scroll on one single page? I tried to set overflow: hidden on the specific page but that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, thanks for the explanation, I changed it, thanks. Yes, it does work, albeit slowly. My end use case is a MUD/telnet client which will scroll a lot more lines, faster. I’ll play around with using the call_later callback.
Thanks again!
tom
From: Dave Pearson @.> Sent: Tuesday, December 6, 2022 9:09 AM To: Textualize/textual @.> Cc: Tom Allen @.>; Comment @.> Subject: [EXTERNAL]Re: [Textualize/textual] scroll_end off by one (Issue #1215)
self.call_later(self.body.scroll_end(animate=False, duration=0.01, easing=“linear”))
Note that what you’ve done there isn’t the same as what will suggested though. You’re passing the result of scroll_end to call_later, whereas well is passing the function scroll_end to call_later. call_laterhttps://textual.textualize.io/api/message_pump/#textual.message_pump.MessagePump.call_later takes a callback function.
Try it how Will wrote it.
— Reply to this email directly, view it on GitHubhttps://github.com/Textualize/textual/issues/1215#issuecomment-1339445570, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVAFQFTZ6IQOBSD4YE6AZ2LWL5CLDANCNFSM6AAAAAASEAMEUU. You are receiving this because you commented.Message ID: @.***>
Hello
I believe because
action_add_row()
is synchronous, the relevant dimensions won’t have been updated by the timescroll_end()
is called.(Details:
add_row()
does some stuff then callscheck_idle()
, sending out a message which is eventually handled byDataTable.on_idle()
, where the dimensions are updated.)I’m not sure if there’s a simple way to guarantee the behavior you want, but the following worked the few times I tested it:
Some other methods, such as
Widget.mount()
, return an awaitable. It could be useful ifDataTable.add_row()
did too.