Code Monkey home page Code Monkey logo

Comments (9)

willmcgugan avatar willmcgugan commented on May 18, 2024 1

Hi @samuelcolvin Horizontal scrolling should be fixed in v0.1.11 (just released)

from textual.

willmcgugan avatar willmcgugan commented on May 18, 2024

Hi Samuel,

Thanks for the bug report. The horizontal scroll bar should show automatically if he renderable is wider than the widget size, but I can see from a quick test that it isn't. Will fix that in the next update.

from textual.

samuelcolvin avatar samuelcolvin commented on May 18, 2024

Thanks so much, not sure if it's part of the same problem, but horizontal scrolling didn't seem to be working at all - e.g. if I used the left and right arrows, no scrolling occurred.

from textual.

willmcgugan avatar willmcgugan commented on May 18, 2024

Yeah, they aren't showing anywhere. It was working at one point. But they haven't been as well tested as vertical scrollbars.

from textual.

samuelcolvin avatar samuelcolvin commented on May 18, 2024

thanks so much. I'll test now.

from textual.

samuelcolvin avatar samuelcolvin commented on May 18, 2024

Thanks so much, works brilliantly.

The only small problem I found was that by default I could scroll vertically with the arrow keys, but not horizontally.

I fixed that fairly easily as follows:

from rich.table import Table

from textual import events
from textual.app import App
from textual.widgets import ScrollView


class CustomScrollView(ScrollView):
    def move_left(self) -> None:
        self.target_x -= 2
        self.animate("x", self.target_x, speed=80, easing="out_cubic")

    def move_right(self) -> None:
        self.target_x += 2
        self.animate("x", self.target_x, speed=80, easing="out_cubic")


class MyApp(App):
    """An example of a very simple Textual App"""

    async def on_load(self, event: events.Load) -> None:
        await self.bind("q", "quit", "Quit")

    def on_key(self, event: events.Key):
        if event.key == 'left':
            self.body.move_left()
        elif event.key == 'right':
            self.body.move_right()

    async def on_mount(self, event: events.Mount) -> None:

        self.body = body = CustomScrollView(auto_width=True)

        await self.view.dock(body)

        async def add_content():
            table = Table(title="Demo")

            for i in range(40):
                table.add_column(f"Col {i + 1}", style="magenta")
            for i in range(200):
                table.add_row(*[f"cell {i},{j}" for j in range(40)])

            await body.update(table)

        await self.call_later(add_content)
        self.log('HELLO')


MyApp.run(title="Simple App", log="textual.log")

Happy to add that to the example if you don't think it should work out of the box?

from textual.

samuelcolvin avatar samuelcolvin commented on May 18, 2024

the other thing I noticed is that rendering the table is relatively slow, even for this modest table. Any idea what's causing that slow down and if it can be solved?

I'm thinking of a tool that can easily show a table thousands of rows a hundred columns, if I extrapolated the current performance to that it would get very slow to load.

from textual.

willmcgugan avatar willmcgugan commented on May 18, 2024

The scroll view widget should probably handle the left/right keys. I'll add that in the next update.

Large tables will be slow to render in a ScrollView, since it renders everything up front. There will eventually be a datatable widget that is optimized to only render the visible area.

from textual.

github-actions avatar github-actions commented on May 18, 2024

Did I solve your problem?

Consider sponsoring my work on Textual with a monthly donation.

Or buy me a coffee to say thanks.

Will McGugan

from textual.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.