Prompt
Bases: ActionsHandler
Source code in pzp/prompt.py
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
__init__(default=None, prompt_str='', type=None, value_proc=None, keys_binding=None, output_stream=sys.stderr)
Initializate Prompt object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
default |
Optional[Any]
|
The default value to use if no input happens |
None
|
prompt_str |
str
|
The input prompt |
''
|
type |
Optional[Any]
|
The type to use to check the value against |
None
|
value_proc |
Optional[Callable[[str], Any]]
|
Type conversion function |
None
|
keys_binding |
Optional[KeysBinding]
|
Custom keys binding |
None
|
output_stream |
TextIO
|
Output stream |
sys.stderr
|
Source code in pzp/prompt.py
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 |
|
abort(key_event)
Cancel
Source code in pzp/prompt.py
117 118 119 120 |
|
accept(key_event)
Confirm
Source code in pzp/prompt.py
106 107 108 109 110 111 112 113 114 115 |
|
ignore()
Do nothing
Source code in pzp/prompt.py
122 123 124 125 |
|
prepare_result()
Return the line converted to the correct type or the default value if the line is empty
Source code in pzp/prompt.py
96 97 98 99 100 101 102 103 104 |
|
process_key(ch=None)
Process the pressed key
Source code in pzp/prompt.py
78 79 80 81 82 83 84 85 86 87 |
|
setup(input=None)
Setup Prompt execution
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input |
Optional[str]
|
initial string |
None
|
Source code in pzp/prompt.py
50 51 52 53 54 55 56 57 58 59 |
|
show(input=None)
Open pzp and return the selected element
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input |
Optional[str]
|
initial string |
None
|
Raises:
Type | Description |
---|---|
AcceptAction
|
Raises when the user presses a key that is mapped to the "accept" action. |
AbortAction
|
Raises when the user presses a key that is mapped to the "abort" action. |
CustomAction
|
Raises when the user presses a key that is mapped to the "custom" action. |
Source code in pzp/prompt.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
update_screen()
Update the screen
Source code in pzp/prompt.py
89 90 91 92 93 94 |
|