"timeout" conditions are not handled well by this library. When a timeout occurs, an exception is thown (I would have expected the "code" that is returned to be "timeout").
dialog.DialogError('the dialog-like program exited with status 3 (which was passed to it as the DIALOG_ERROR environment variable). Sometimes, the reason is simply that dialog was given a height or width parameter that is too big for the terminal in use. Its output, with leading and trailing whitespace stripped, was:\n\ntimeout')
Hello,
Sorry for replying “a bit” late: my ISP Free.fr and SourceForge can't get along, so notification or SourceForge mailing-list emails get lost. Regarding what you wrote:
1) This is most probably related to layers below
pythondialog
.2) Without a minimal example to reproduce, this report is unlikely to be of any use, I'm afraid.
I can no longer reproduce this in a modern setup. Instead, timeouts result in an "esc" code, which also seems wrong.
Example:
import dialog
if name == 'main':
a = dialog.Dialog().checklist(
'Stuff',
choices=
['T1', 'One', 0,
['T2', 'Two', 0],
],
timeout=5)
print(a)
Run that and then just wait 5 seconds. I would expect it to say it encountered a timeout, instead I see "('esc', [])"
Thanks for the minimal example. The
Dialog.checklist()
method returnsDialog.ESC
because the underlyingdialog
program returnsDIALOG_ESC
. Support forDIALOG_TIMEOUT
indialog
was probably added after I implemented the exit status handling. With this patch applied:the following example (essentially yours) distinguishes between “Esc pressed” and a timeout:
This is fixed in 8ffc85fc1 (the commit message uses a wrong URL for the issue, sorry).
Commit df4f82a63c should improve support for this
timeout
option. I hope no widget that normally produces output is broken by the empty output in case of a timeout.Great. Can you push it out as a pip update?
I will, but unfortunately, I don't think
dialog
supports--timeout
for all widgets. So far, I've seen it work withchecklist
(here),msgbox
(in the latest version of demo.py) andmenu
(quick hack on demo.py). AFAICS, it doesn't work withinputbox
nor withmixedform
. I haven't tested with other widgets. All this withdialog
version 1.3-20201126 from Debian unstable (which suffers from this little problem...).pythondialog 3.5.2 is out with the changes (on PyPI.org, among others).
Strange. I can still reproduce the problem with your updated library.
$ dialog --version
Version: 1.3-20190808
$ pip3 freeze | grep pythondialog
pythondialog==3.5.2
Strange indeed. The following works fine for me:
Are you sure you ran your test with the correct pythondialog? The above script should print the version that is being used.
One possible explanation is that your dialog program is too old. Indeed, I tested the above with dialog 1.3-20201126, and in case I let the timeout expire, the output is:
but with dialog 1.3-20190211 (on Debian buster) and pythondialog 3.5.2 too, the same test prints this:
So, maybe you need to upgrade dialog to make this work.
Alright. Thanks for your work. I'm not going to bother trying to upgrade my dialog installation, I'll just wait for my distro to get it.
All right, good night. :)
Hi,
FYI, building dialog from source is not difficult (you may need to install a few -dev packages for its build dependencies). I just did it for the latest version, namely 1.3-20210621, with the following commands:
(actually, I added
-j7
to themake
command). I specified the--prefix
just in case I would later do amake install
, but I usually don't perform this step: for my testing, dialog doesn't need to be installed. Then I applied the following temporary change to tell pythondialog's demo.py to use the newly-built executable:and ran
./examples/demo.py --test-suite
. from the root of the pythondialog repository. This allowed me to confirm that dialog 1.3-20210621 is good for pythondialog.