keyboard_button
This module provides a keyboard-accessible button.
KeyboardButton
Bases: Button
A button with keyboard mnemonics in mind.
Shoutout to the HackerNews thread where this was originally suggested
https://news.ycombinator.com/item?id=30517299#30533444
Source code in pytermgui/widgets/keyboard_button.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
__init__(label, onclick, index=0, bound=None)
Initializes a KeyboardButton.
For example, KeyboardButton("Help")
will look like: "[ (H)elp ]", and
KeyboardButton("Test", index=1)
will give "[ T(e)st ]"
Parameters:
Name | Type | Description | Default |
---|---|---|---|
label |
str
|
The label of the button. |
required |
onclick |
Callable[[Button], Any]
|
The callback to be executed when the button is activated. |
required |
index |
int
|
The index of the label to use as the binding character. |
0
|
bound |
str | None
|
The keybind that activates this button. Defaults to |
None
|
Source code in pytermgui/widgets/keyboard_button.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|