trogon icon indicating copy to clipboard operation
trogon copied to clipboard

Make on_mount callback customizable

Open gitseti opened this issue 11 months ago • 1 comments

Introduce the ability to customize the on_mount callback of the underlying Textual App. By allowing users to specify the on_mount behavior, they can define their own logic for the application's mount phase. For example, users can change the default theme of the generated Trogon app.

I wasn't entirely sure if this behavior could be achieved in a different way, so I implemented it using the on_mount callback. However, I'm open to adjust the implementation if there's a more idiomatic or better approach to achieve the same result.

Example: Change default theme

def on_mount(app: App):
    app.theme = 'tokyo-night'

@tui(on_mount=on_mount)
@click.command()
def hello_world():
    """Prints 'Hello world'."""
    click.echo('Hello world.')

gitseti avatar Dec 29 '24 15:12 gitseti

Thanks for your patience here @gitseti. I recognize that the on_mount entry point might be useful for a variety of reasons. That said, I know that the theme in particular can be altered by setting the TEXTUAL_THEME environment variable already, and I would like to hear from you or others some additional use cases around customizing on_mount to determine whether it feels worth taking on this customization as an additional moving part!

daneah avatar Mar 06 '25 11:03 daneah