Skip to content

Capture traceback in log file #5933

Discussion options

You must be logged in to vote

Yes this is possible, not only that but there's an easy way to do it built right into Rich. Its actually not super well documented, I recall when I figured this out I had to dig through some stuff quite manually. But now I can save you from having to go through the same pain. Here's a working example.

# Python standard lib
from datetime import datetime
# Textual and Rich
from textual.app import App
from textual.widgets import Static, Button
from textual.containers import Container  
from rich.console import Console
from rich.traceback import Traceback


class TextualApp(App[None]):

    CSS = """
    Screen { align: center middle; }
    #my_static { border: solid blue; width: auto;}
    """

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@gpregger-ethz
Comment options

@edward-jazzhands
Comment options

Answer selected by gpregger-ethz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #5931 on July 07, 2025 12:14.