Skip to content
Discussion options

You must be logged in to vote

Unless otherwise told not to, bindings inherit. So you can generally inherit from a widget and add your own bindings. For example:

from pathlib import Path

from textual.app     import App, ComposeResult
from textual.widgets import Header, Footer, MarkdownViewer
from textual.binding import Binding

class ViLikeMarkdownViewer( MarkdownViewer ):

    BINDINGS = [
        Binding( "j", "up", "", show=False ),
        Binding( "k", "down", "", show=False ),
    ]

    def action_up( self ) -> None:
        self.scroll_up()

    def action_down( self ) -> None:
        self.scroll_down()

class ViLikeMarkdownApp( App[ None ] ):

    def compose( self ) -> ComposeResult:
        yield Header()
…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@TomJGooding
Comment options

@davep
Comment options

@tthkbw
Comment options

Answer selected by tthkbw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants