Skip to content

GUI: Select tag numbers shortcuts #37

@e3rd

Description

@e3rd

We create a form

#!/usr/bin/env python3
from dataclasses import dataclass
from typing import Literal
from mininterface import run

@dataclass
class Env:
    foo1: str
    foo2: int
    foo3: float
    foo4: bool
    foo5: Literal["one", "two", "three"]


m = run(Env)
print(m.env)
Image

Make it work so that if a select form is focused, hitting numbers would select the corresponding element, here hitting '1' would select 'one', and '2' would select 'two'.

Here, we bind shortcuts for mnemonics:

adaptor.bind_shortcut(f"<Alt-{char}>", taking_focus)

When done, add the shortcuts to this manager:

self.shortcuts = set(["F1: Show this help", "Enter: Submit form", "Escape: Cancel"])

We might need to turn the set into a class and add a 'remove' method or something so that the shortcut appear and disappear on de/focusing the select tag.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions