Skip to main content

CheckBox / OptionBox

Python class for creating list of CheckBox and OptionBox. CheckBox has the feature of being multi choice and OptionBox of simple choice.

Prerequisites

Developed and tested in Linux and Python 3.6

Installing

pip3 install ebx_checkbox

or from source:

python3 -m pip install [your_path]/ebx_checkbox/

Functions

get_CheckList

get_CheckList(str_Title, InitialLine, InitialColumn, SizeLimit, Options, ClearLine=True, Options_sets=[]):

Description: Create a list of checkBox and multiple choices, return a list of 1 (check) and 0 (uncheck) for all itens (on same order) of Options parameter

Parameter Description
str_Title: Title of the list
InitialLine: First line on screen where the list will br printed.
InitialColumn: Column on screen where the list will br printed.
SizeLimit: Limit (quantity) in lines that will be shown on screen, navigation is by Up and Down arrows.
Options: List of itens to be printed.
ClearLine: (True or False) Clear entire line before print?.
Options_sets: (Optional) List of predefined choices (mark) of 1 (Checked) or 0 (Unchecked). The list must have same len of Options, and set 1 on index that you want show checked.

Return: List of 1 (check) and 0 (uncheck) for all itens (on same order) of Options parameter. -1 if canceled (Esc)

###Information:

  • Ctrl + A To check entire list
  • Ctrl + N To uncheck entire list
  • Space to select item
  • Arrows:
    -    Up: Move to the above item
    -    Down: Move to the item below
    -    Esc: Cancel selection and return -1

get_OptionList

get_OptionList (str_Title, InitialLine, InitialColumn, SizeLimit, Options, ClearLine=True, Options_Index=-1)

Description: Create a list of OptionBox and only one choice, return a list of 1 (check) and 0 (uncheck) for all itens (on same order) of Options parameter

Parameter Description
str_Title: Title of the list
InitialLine: First line on screen where the list will br printed
InitialColumn: Column on screen where the list will br printed
SizeLimit Limit (quantity) in lines that will be shown on screen, navigation is by Up and Down arrows
Options: List of itens to be printed
ClearLine: (True or False) Clear entire line before print?
Options_Index: (Optional) Index of predefined choice (mark) of 1 (Checked) or 0 (Unchecked).

Return: List of 1 (check) and 0 (uncheck) for all itens (on same order) of Options parameter. -1 if canceled (Esc)

Information: ###Information:

  • Space to select item
  • Arrows:
    -    Up: Move to the above item
    -    Down: Move to the item below
    -    Esc: Cancel selection and return -1

Examples of use

ex_checkbox.py:

import ebx_checklist

obj_Checklist = ebx_checklist.Options()

lst_Hosts = [{'IP': '15.128.89.74', 'DC': u'asia-dc'}, {'IP': '15.128.89.75', 'DC': u'asia-dc'}, {'IP': '15.128.89.76', 'DC': u'asia-dc'},
             {'IP': '15.128.89.77', 'DC': u'asia-dc'}, {'IP': '15.128.89.78', 'DC': u'asia-dc'}, {'IP': '15.128.89.79', 'DC': u'asia-dc'},
             {'IP': '15.128.89.80', 'DC': u'asia-dc'}, {'IP': '15.128.89.81', 'DC': u'asia-dc'}, {'IP': '15.128.89.88', 'DC': u'asia-dc'},
             {'IP': '15.128.89.89', 'DC': u'asia-dc'}, {'IP': '15.128.89.90', 'DC': u'asia-dc'}, {'IP': '15.128.89.91', 'DC': u'asia-dc'},
             {'IP': '15.128.89.92', 'DC': u'asia-dc'}, {'IP': '15.128.89.93', 'DC': u'asia-dc'}, {'IP': '15.128.89.94', 'DC': u'asia-dc'},
             {'IP': '15.128.89.95', 'DC': u'asia-dc'}, {'IP': '15.128.89.96', 'DC': u'asia-dc'}, {'IP': '15.128.89.97', 'DC': u'asia-dc'},
             {'IP': '15.128.89.98', 'DC': u'asia-dc'}, {'IP': '15.128.89.99', 'DC': u'asia-dc'}, {'IP': '15.128.89.100', 'DC': u'asia-dc'},
             {'IP': '15.128.89.101', 'DC': u'asia-dc'}, {'IP': '15.128.89.102', 'DC': u'asia-dc'}, {'IP': '15.128.89.103', 'DC': u'asia-dc'},
             {'IP': '15.130.89.74', 'DC': u'eu-dc'}, {'IP': '15.130.89.75', 'DC': u'eu-dc'}, {'IP': '15.130.89.76', 'DC': u'eu-dc'},
             {'IP': '15.130.89.77', 'DC': u'eu-dc'}, {'IP': '15.130.89.78', 'DC': u'eu-dc'}, {'IP': '15.130.89.79', 'DC': u'eu-dc'},
             {'IP': '15.130.89.80', 'DC': u'eu-dc'}, {'IP': '15.130.89.81', 'DC': u'eu-dc'}, {'IP': '15.130.89.82', 'DC': u'eu-dc'},
             {'IP': '15.130.89.83', 'DC': u'eu-dc'}, {'IP': '15.130.89.84', 'DC': u'eu-dc'}, {'IP': '15.130.89.85', 'DC': u'eu-dc'},
             {'IP': '15.130.89.92', 'DC': u'eu-dc'}, {'IP': '15.130.89.93', 'DC': u'eu-dc'}, {'IP': '15.130.89.94', 'DC': u'eu-dc'},
             {'IP': '15.130.89.95', 'DC': u'eu-dc'}, {'IP': '15.130.89.96', 'DC': u'eu-dc'}, {'IP': '15.130.89.97', 'DC': u'eu-dc'},
             {'IP': '15.130.89.98', 'DC': u'eu-dc'}, {'IP': '15.130.89.99', 'DC': u'eu-dc'}, {'IP': '15.130.89.100', 'DC': u'eu-dc'},
             {'IP': '15.130.89.101', 'DC': u'eu-dc'}, {'IP': '15.130.89.102', 'DC': u'eu-dc'}, {'IP': '15.130.89.103', 'DC': u'eu-dc'},
             {'IP': '15.135.51.19', 'DC': u'america-dc'}, {'IP': '15.135.51.20', 'DC': u'america-dc'}, {'IP': '15.135.51.21', 'DC': u'america-dc'},
             {'IP': '15.135.51.22', 'DC': u'america-dc'}, {'IP': '15.135.51.23', 'DC': u'america-dc'}, {'IP': '15.135.51.24', 'DC': u'america-dc'},
             {'IP': '15.135.187.74', 'DC': u'america-dc'}, {'IP': '15.135.187.75', 'DC': u'america-dc'}, {'IP': '15.135.187.76', 'DC': u'america-dc'},
             {'IP': '15.135.187.77', 'DC': u'america-dc'}, {'IP': '15.135.187.78', 'DC': u'america-dc'}, {'IP': '15.135.187.79', 'DC': u'america-dc'},
             {'IP': '15.135.187.86', 'DC': u'america-dc'}, {'IP': '15.135.187.87', 'DC': u'america-dc'}, {'IP': '15.135.187.88', 'DC': u'america-dc'},
             {'IP': '15.135.187.89', 'DC': u'america-dc'}, {'IP': '15.135.187.90', 'DC': u'america-dc'}, {'IP': '15.135.187.91', 'DC': u'america-dc'},
             {'IP': '15.135.187.92', 'DC': u'america-dc'}, {'IP': '15.135.187.93', 'DC': u'america-dc'}, {'IP': '15.135.187.94', 'DC': u'america-dc'},
             {'IP': '15.135.187.95', 'DC': u'america-dc'}, {'IP': '15.135.187.96', 'DC': u'america-dc'}, {'IP': '15.135.187.97', 'DC': u'america-dc'}]

lst_OptionDCs = [d['DC'] for d in {v['DC']:v for v in lst_Hosts}.values()]
print("\033c")

###################################################################################################################################

lst_DataCentersCheck = obj_Checklist.get_OptionList('DC to restart', 5, 20, 20, lst_OptionDCs, ClearLine=True, Options_Index=-1)

lst_indexes = [index for index in range(len(lst_DataCentersCheck)) if lst_DataCentersCheck[index] == 1]
lst_DataCentersFilter = [lst_OptionDCs[i] for i in lst_indexes]

lst_OptionHosts = [d['DC'] + ' - ' + d['IP'] for d in lst_Hosts if d['DC'] in lst_DataCentersFilter]

lst_HostsCheck = obj_Checklist.get_CheckList('Hosts to restart', 5, 120, 20, lst_OptionHosts, ClearLine=False, Options_sets=[])

lst_tmp_hosts = [d['IP'] for d in lst_Hosts if d['DC'] in lst_DataCentersFilter]
lst_indexes = [index for index in range(len(lst_HostsCheck)) if lst_HostsCheck[index] == 1]
lst_DataCentersFilter = [lst_tmp_hosts[i] for i in lst_indexes]

for host in lst_DataCentersFilter:
    print(host)

Call python:

python3 ex_checkbox.py




                     DC to restart                                                                                       Hosts to restart

                        ( ) - asia-dc                                                                                       [ ] - eu-dc - 15.130.89.74
                        (O) - eu-dc                                                                                         [ ] - eu-dc - 15.130.89.75
                        ( ) - america-dc                                                                                    [ ] - eu-dc - 15.130.89.76
                                                                                                                            [X] - eu-dc - 15.130.89.77
                                                                                                                            [ ] - eu-dc - 15.130.89.78
                                                                                                                            [X] - eu-dc - 15.130.89.79
                                                                                                                            [ ] - eu-dc - 15.130.89.80
                                                                                                                            [X] - eu-dc - 15.130.89.81
                                                                                                                            [ ] - eu-dc - 15.130.89.82
                                                                                                                            [ ] - eu-dc - 15.130.89.83
                                                                                                                            [X] - eu-dc - 15.130.89.84
                                                                                                                            [ ] - eu-dc - 15.130.89.85
                                                                                                                            [X] - eu-dc - 15.130.89.92
                                                                                                                            [ ] - eu-dc - 15.130.89.93
                                                                                                                            [X] - eu-dc - 15.130.89.94
                                                                                                                            [ ] - eu-dc - 15.130.89.95
                                                                                                                            [ ] - eu-dc - 15.130.89.96
                                                                                                                            [ ] - eu-dc - 15.130.89.97
                                                                                                                            [ ] - eu-dc - 15.130.89.98
                                                                                                                            [ ] - eu-dc - 15.130.89.99

Versioning

=======================================================================================
== Log Changes: 
== Date:            2021-05-13
== Author:          Fausto Branco
== Version:         1.0.1
== Description:     Initial Version
=================================================================================

License

Metadata

Release files for ebx-checkbox 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ebx-checkbox 1.0.1
File Size Uploaded Provenance Actions
ebx_checkbox-1.0.1.tar.gz 19.6 kB Without provenance Details for ebx_checkbox-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ebx-checkbox 1.0.1
File Interpreter ABI Platform Actions
ebx_checkbox-1.0.1-py3-none-any.whl Python 3 none any Details for ebx_checkbox-1.0.1-py3-none-any.whl

Total release size: 37.9 kB

Release files / ebx_checkbox-1.0.1.tar.gz

Download URL ebx_checkbox-1.0.1.tar.gz
Size 19.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f667c6a0e91e5e6e1057813760a7be09d861ec57185c4d1584594d410066cc75
BLAKE2b-256 checksum
How to use checksums
947944dd84ea86d1feafd95adec7bdfbb2dcc735b9acd5a67624cc87eb03ce25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.8

Release files / ebx_checkbox-1.0.1-py3-none-any.whl

Download URL ebx_checkbox-1.0.1-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a7f2e09ca9152ebe6ae318319d22316c2873d8de49d825aec4dbe2cf13ac7553
BLAKE2b-256 checksum
How to use checksums
52a7f339fa64d53f8d679290a40e6bfb8dd3c1176d6a1e7c9634c48a2a10abeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.8

Security for ebx-checkbox 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page