prompt-toolkit / prompt-toolkit/python-prompt-toolkit

Float based shortcuts improvements

Open
#1,398 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
10.6k
Forks
815
PR merge metrics
No merged PRs in 30d

Description

The shortcuts implementations of various dialogs are awesome and they need a set of variants for use in fullscreen apps.
I've implemented my own by essentially replicating the existing shortcuts each as a class that then wraps the dialog in a float and takes an argument for "parent_layout" like so:

class PopupRadioInput:
    def __init__(self, parent_layout=None,
                title="",
                text="",
                ok_text="Ok",
                cancel_text="Cancel",
                values=None,
                return_handler=None,
                ):

<snip>
    def show(self):
        self.parent_layout.container.floats.append(self.main_float)
        self.restore_focus_pointer = self.parent_layout.current_window
        self.parent_layout.focus(self.radio_list)

    def hide(self):
        self.parent_layout.container.floats.remove(self.main_float)
        self.parent_layout.focus(self.restore_focus_pointer)

I'd like to help contribute this back to the community but it's not clear if this is the desirable api format, taking a Layout object just seemed the easiest.
Before I submit this back as a PR: Is this the preferred API? or is there a better parent-ing that feels more natural you'd like to see?
@jonathanslenders could you please let me know your preference and I'd be happy to officially put together the PR?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing shortcut implementations for dialogs and the proposed parent_layout, float, show, and hide behavior described in the issue. Confirm the preferred API with the maintainer before implementing anything. Done means an agreed design for fullscreen float-based dialog variants and, if accepted, a complete contribution using that API.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.