Callbacks update
Callbacks update
Major changes
- Python 3.8+ is now required to use Visual-dialog (due to improvements in typing hinting).
New features
Callback
Callback support has been completely redesigned.
- Passing arguments via
cargs
to the callback is no longer possible. - Added the possibility to pass several callbacks to
char_by_char
andword_by_word
.
callback
argument must now be an iterable of callables (argument has been renamedcallbacks
accordingly).
It defaults to an empty tuple. - Several arguments are now passed to callbacks when they are executed:
- For
char_by_char
method:- the instance of the class used (
self
), character written and index of the character in the current word being written.
- the instance of the class used (
- For
word_by_word
method:- the instance of the class used (
self
) and word written.
- the instance of the class used (
- For
See the implementation for more details.
API changes
- The unit of the duration parameters (
delay
,downtime_chars_delay
, andrandom_delay
) is now milliseconds
due to the use ofcurses.napms
instead oftime.sleep
. Therefore, the values passed to these parameters
must now be of typeint
and no longer ofUnion[int, float]
. - The error message of the
PanicError
exception is now more precise. - Import of all of each submodule when importing visualdialog.
BaseTextBox.confirm_dialog_keys
is now defaults on[" "]
.BaseTextBox.key_detection
now accepts only a string. It can be"getkey"
,"getch"
, or"get_wch"
.
These strings represent the name of the input capture methods ofcurses
.
Renaming
In BaseTextBox
and DialogBox
:
-
Instance variable:
confirm_dialog_key
toconfirm_dialog_keys
.panic_key
topanic_keys
.key_detection_mode
tokey_detection
.
-
Method parameters:
cut_char
parameter toword_delimiter
inchar_by_char
andword_by_word
.callback
parameter tocallback
inchar_by_char
andword_by_word
.
-
Method name:
BaseTextBox.getkey
method toBaseTextBox.get_input
.
In submodules:
-
visualdialog.utils
TextAttributes
context manager toTextAttr
.
-
visualdialog.type
CursesKeyConstant
andCursesKeyConstants
toCursesKey
andCursesKeys
.
Bug fix
- Fixed the bug that occurred when several key presses were recorded while scrolling the text in a dialog box.
Ifn
keystrokes had been registered,n
text scrolling was passed without waiting for an input.