
Security News
Open Source CAI Framework Handles Pen Testing Tasks up to 3,600ร Faster Than Humans
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600ร faster than humans.
The easiest way to create interactive console menus in Python
Report bug
ยท
Request feature
JSON Menu is a Python library created by Xavi Burgos that lets you create interactive console menus from basic JSON structures. With just a few lines of code, you can build user-friendly interfaces for your Python scripts.
The menu generated by JSON Menu will be displayed as the following example:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ My first menu โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 1. My first action โ
โ 2. Submenu โ
โ 0. Exit โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Select an option:
To install JSON Menu, you can use the following pip command:
pip install jsonmenu
Alternatively, you can clone the repository from GitHub or download the source code from the releases page and include the jsonmenu.py
file in your project.
Once installed, you can import the library in your Python script with the following line:
from jsonmenu import JsonMenu
To create a menu, you need to define a JSON structure with the following format:
menu_data = [
{
"label": "My first action",
"action": my_function
},
{
"label": "Submenu",
"submenu": [
{
"label": "Option 1",
"action": custom_function_1
},
{
"label": "Option 2",
"action": custom_function_2
}
]
}
]
Also, you can add an options dictionary to customize the menu, explained at options section.
custom_options = {
"theme": "rounded",
# More options here...
}
Then, you can create the menu with the following code:
jm = JsonMenu("My first menu", menu_data, custom_options)
jm.show()
A compact version of the previous code to create and show the menu is the following:
jm = JsonMenu("My first menu", [
{
"label": "My first action",
"action": my_function
},
{
"label": "Submenu",
"submenu": [
{
"label": "Option 1",
"action": custom_function_1
},
{
"label": "Option 2",
"action": custom_function_2
}
]
}
], { "theme": "rounded" })
jm.show()
The options dictionary allows you to customize the appearance and behavior of the menu. The following options are available:
Option | Description | Default value | Possible values |
---|---|---|---|
back_menu | Previous menu to return when the user selects the 0 option. If not defined, the menu will close. | None | JsonMenu object |
clear | Clear the console before showing the menu. This option is useful to avoid cluttering the console with previous outputs. | False | True , False |
debug | Show debug information in the console. This option is useful for development and testing. Warnings will not be displayed if clear option is enabled (console is cleared before showing the menu). | False | True , False |
width | Width of the menu in characters. | 31 | int |
language | Language of the menu. Also a dictionary could be passed, and the menu will be use the provided custom translations. | en | ar , ca , de , en , es , fr , hi , it , ja , ko , nl , pt , ru , sv , tr , zh , <custom dictionary> |
theme | Theme of the menu. Also a dictionary could be passed, and the menu will be use the provided custom theme. | unicode | ascii , unicode , bold , double , rounded , dotted , striped , <custom dictionary> |
A custom language dictionary can be passed to the language
option. The dictionary must contain the following keys:
Key | Description | English value |
---|---|---|
back | Text for the back option. | Back |
exit | Text for the exit option. | Exit |
invalid_option | Text for the invalid option message. | Invalid option |
select_option | Text for the select option message. | Select an option |
press_enter | Text for the press enter to continue message. | Press "Enter" to continue |
A custom theme dictionary can be passed to the theme
option. The dictionary must contain the following keys:
Key | Description | Unicode value |
---|---|---|
tl | Top left corner of the menu. | โ |
tr | Top right corner of the menu. | โ |
cl | Center left corner of the menu. | โ |
cr | Center right corner of the menu. | โค |
bl | Bottom left corner of the menu. | โ |
br | Bottom right corner of the menu. | โ |
h | Horizontal line of the menu. | โ |
v | Vertical line of the menu. | โ |
Within the download you'll find the following directories and files, logically grouping common assets. You'll see something like this:
jsonmenu/
โโโ jsonmenu
โ โโโ __init__.py
โ โโโ jsonmenu.py
โโโ setup.py
โโโ CONTRIBUTING.md
โโโ LICENSE
โโโ README.md
Have a bug or a feature request? Please first read the issue guidelines and search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.
Please read through our contributing guidelines. Included are directions for opening issues, coding standards, and notes on development.
Xavier Burgos
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600ร faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.