CITGuru / PyInquirer

A Python module for common interactive command line user interfaces
MIT License
1.91k stars 235 forks source link

Checkbox 'checked: True' does not appear to work when using a 'value' option as well. #110

Open rmkraus opened 4 years ago

rmkraus commented 4 years ago

I use the following array for choices:

[<PyInquirer.separator.Separator object at 0x7fe1c5896048>, {'name': 'nvme0n1', 'value': 'node-0:nvme0n1', 'checked': True}, {'name': 'nvme1n1', 'value': 'node-0:nvme1n1', 'checked': True}, {'name': 'nvme2n1', 'value': 'node-0:nvme2n1', 'checked': True}, {'name': 'nvme3n1', 'value': 'node-0:nvme3n1', 'checked': True}, {'name': 'sda', 'value': 'node-0:sda', 'checked': True}, {'name': 'sdb', 'value': 'node-0:sdb', 'checked': True}]

Note that all entries have checked set to True. However, when PyInquirer displays the menu, none of the options are checked.

$ pip3 freeze ansible==2.9.9 cachetools==4.1.0 certifi==2020.4.5.1 cffi==1.14.0 chardet==3.0.4 cryptography==2.9.2 dictdiffer==0.8.1 dnspython==1.16.0 google-auth==1.15.0 idna==2.9 Jinja2==2.11.2 jmespath==0.10.0 kubernetes==11.0.0 MarkupSafe==1.1.1 oauthlib==3.1.0 openshift==0.11.0 prompt-toolkit==1.0.14 pyasn1==0.4.8 pyasn1-modules==0.2.8 pycparser==2.20 Pygments==2.6.1 PyInquirer==1.0.3 python-dateutil==2.8.1 python-hpilo==4.3 python-string-utils==1.0.0 PyYAML==5.3.1 regex==2020.5.14 requests==2.23.0 requests-oauthlib==1.3.0 rsa==4.0 ruamel.yaml==0.16.10 ruamel.yaml.clib==0.2.0 six==1.14.0 urllib3==1.25.9 wcwidth==0.1.9 websocket-client==0.57.0

realgam3 commented 4 years ago

I have a similar problem: When using different name and value in the choices it will not count the choice as checked. It show it selected but never really select the items...

[Works] same name and value:

from PyInquirer import prompt

print(prompt([
    {
        'type': 'checkbox',
        'name': 'ids',
        'message': 'ids:',
        'choices': [
            {'name': '100000001', 'value': '100000001', 'checked': True},
            {'name': '100000002', 'value': '100000002', 'checked': False},
            {'name': '100000003', 'value': '100000003', 'checked': False},
            {'name': '100000004', 'value': '100000004', 'checked': True},
        ]
    }
]))

? ids: done (2 selections) {'ids': ['100000001', '100000004']}

[Dosn't Work] different name and value:

from PyInquirer import prompt

print(prompt([
    {
        'type': 'checkbox',
        'name': 'ids',
        'message': 'ids:',
        'choices': [
            {'name': 'name_1', 'value': '100000001', 'checked': True},
            {'name': 'name_2', 'value': '100000002', 'checked': False},
            {'name': 'name_3', 'value': '100000003', 'checked': False},
            {'name': 'name_4', 'value': '100000004', 'checked': True},
        ]
    }
]))

? ids: done (2 selections) {'ids': []}

realgam3 commented 4 years ago

Dear @CITGuru, I saw you fixed it in the master branch... Is it possible to release a minor version 1.0.4 with the fix to pypi?

CITGuru commented 3 years ago

@realgam3 this will be released soon.