Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't unset the exit key #115

Closed
lenormf opened this issue May 23, 2021 · 3 comments
Closed

Can't unset the exit key #115

lenormf opened this issue May 23, 2021 · 3 comments
Assignees
Labels
Bug Something isn't working Core Add for issues having to do with core functions Good first issue Good for newcomers
Milestone

Comments

@lenormf
Copy link

lenormf commented May 23, 2021

Describe the bug
I don't want the program to quit upon hitting any one single key. I can't set exit_key to None or 0.

To Reproduce
Steps to reproduce the behavior:

  1. Pass exit_key=None to the PyCUI constructor
  2. Start the UI

Errors:

Traceback (most recent call last):
  File "/home/fle/misc/4dE/./4dE.py", line 65, in <module>
    sys.exit(main(sys.argv))
  File "/home/fle/misc/4dE/./4dE.py", line 51, in main
    root = UserInterface(2, 2)
  File "/home/fle/misc/4dE/./4dE.py", line 12, in __init__
    super().__init__(rows, columns, exit_key=None)
  File "/home/fle/misc/4dE/.env/lib/python3.9/site-packages/py_cui/__init__.py", line 141, in __init__
    exit_key_char = py_cui.keys.get_char_from_ascii(exit_key)
  File "/home/fle/misc/4dE/.env/lib/python3.9/site-packages/py_cui/keys.py", line 44, in get_char_from_ascii
    return chr(key_num)
TypeError: an integer is required (got type NoneType)

Upon passing exit_key=0, the program doesn't start (no output even in debug mode).

Expected behavior
The program doesn't close upon hitting any keys.

@lenormf lenormf added the Bug Something isn't working label May 23, 2021
@lenormf
Copy link
Author

lenormf commented May 23, 2021

My workaround for now is to pass exit_code=1 to the PyCUI constructor.

@jwlodek jwlodek added Core Add for issues having to do with core functions Good first issue Good for newcomers labels May 24, 2021
@PabloLec
Copy link
Contributor

This could be implemented easily.

By returning None if key is None in PyCUI.get_char_from_ascii().
The only other thing to consider would be:

self._init_status_bar_text  = f'Press - {exit_key_char} - to exit. Arrow Keys to move ' \
                                       'between widgets. Enter to enter focus ' \
                                       'mode.'

A simple if-statement would be acceptable I think.

@jwlodek
Copy link
Owner

jwlodek commented May 26, 2021

Also would need to make sure to somehow handle the use of the exit key in the main draw loop if that is None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Core Add for issues having to do with core functions Good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants