Skip to content

[question] Customizing delimiters #1194

Open
@vincent-lg

Description

@vincent-lg

Hi,

This might be a silly question, since I didn't find the answer in the documentation. I really like this tool, great to build old-school console interfaces, and I'm always in for old-school console interfaces and was sorry to miss a tool for doing so in Python. There's just one tiny feature that I miss, or perhaps, I couldn't find.

Boxes in this library use some delimiters to "look nice". These are unicode characters. They might look pretty nice on other consoles. As it stands for me who uses a screen reader (yes, a console application is actually much more accessible with a screen reader), I would much prefer bare ASCII for delimiters. Something with |, -, \ and / which would not look nice for most users I guess. Unicode symbols are read by the screen reader and displayed in Braille. Not only do they "break" the console design, so it's hard to know where everything is, they also tend to slow down navigation pretty much.

So here's an example and here's what I "see":

from prompt_toolkit.formatted_text import HTML
from prompt_toolkit.shortcuts import message_dialog
from prompt_toolkit.styles import Style

example_style = Style.from_dict({
    'dialog':             'bg:#88ff88',
    'dialog frame.label': 'bg:#ffffff #000000',
    'dialog.body':        'bg:#000000 #00ff00',
    'dialog shadow':      'bg:#00aa00',
})

message_dialog(
    title=HTML('<style bg="blue" fg="white">Styled</style> '
               '<style fg="ansired">dialog</style> window'),
    text='Do you want to continue?\nPress ENTER to quit.',
    style=example_style).run()

Straightforward example right from your documentation. And now here's the screen I see:

                          ┌────────────────| Styled dialog window |────────────────┐
                          │                                                        │
                          │ Do you want to continue?                               │
                          │ Press ENTER to quit.                                   │
                          │                                                        │
                          │                      <    Ok    >                      │
                          │                                                        │
                          └────────────────────────────────────────────────────────┘

I guess you don't see the issue yet. Let me add that is displayed by my screen reader like U|J (again, this is over-simplified and not 100% accurate), somewhat appears like U|w and so on for every character used in the frame. So it doesn't look like a frame to me, it looks like a lot of garbage with some understandable text a bit everywhere without logic.

Now, say, if we had an option for to be a -, or to be a /, it would make things so easier to read. I suggest adding an option when creating dialogs (and full screen windows) to disable unicode-delimiters and force delimiters to be ASCII only.

I hope I explained the situation in enough details and you see the problem I have.

Thanks again for this tool and your hard work,

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions