Skip to content

More minimal frame title? #2030

Open
Open

Description

@JDeeth

Frame formats like this:

┌─| Hello |─┐
│World      │
└───────────┘

Is there a straightforward way to draw a frame without the padding round its title?

┌───Hello───┐
│World      │
└───────────┘

Code for the above:

from prompt_toolkit.application import Application
from prompt_toolkit.layout import Layout, VSplit, Window
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.key_binding.bindings.named_commands import end_of_file
from prompt_toolkit.widgets import Frame, TextArea

kb = KeyBindings()
kb.add("c-c")(end_of_file)

frame = Frame(TextArea(text="World", width=11), title="Hello")
root_container = VSplit([frame, Window()])
layout = Layout(root_container)

app = Application(layout=layout, key_bindings=kb)
app.run()

Activity

  1. BrooksPettit commented on Dec 4, 2025

    @BrooksPettit

    I don't think the Frame widget has a way to achieve that using its constructor.

    However, the Frame class is defined in src/prompt_toolkit/widgets/base.py .
    It's only 96 lines long and pretty easy to understand. You could either subclass it and override the "top_row_with_title" attribute, or just copy and paste the class and modify it to your liking.

    I will probably do the same at some point because I want to be able to change the border characters to use double borders, which also isn't supported with the builtin widget. The thin border characters are hard-coded at the module level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions