Comments (1)
Hi @markolofsen
I've updated the examples to be more clear. But the general idea would be as follows:
from consolemenu import ConsoleMenu, Screen
from consolemenu.items import FunctionItem
from consolemenu.prompt_utils import PromptUtils
def input_handler():
pu = PromptUtils(Screen())
# PromptUtils.input() returns an InputResult
result = pu.input("Enter an input")
pu.println("\nYou entered:", result.input_string, "\n")
pu.enter_to_continue()
def main():
menu = ConsoleMenu('My Menu')
my_function_item = FunctionItem("Execute My Function", input_handler)
menu.append_item(my_function_item)
menu.show()
if __name__ == "__main__":
main()
Hope that helps!
from console-menu.
Related Issues (20)
- Textwrap3 import issue with pyinstaller HOT 3
- Suggestion: accept list of menu items as argument to console_menu.append_item
- How to properly exit the menu HOT 1
- Does not dynamically update submenus HOT 2
- add support for selecting by pressing number or letter HOT 3
- Load Menu Definition from a YAML formatted String HOT 2
- Questions about the cascade sub menu HOT 1
- demo doens't work HOT 2
- Feature Request - No menu border
- Request: Additional documentation regarding layered menus HOT 1
- Multiple use of "remove_item" fails
- Add type hints
- Dynamic Menu Items HOT 2
- ImportError: cannot import name 'SelectionMenu' from 'consolemenu' HOT 2
- Add support for Unicode wide characters HOT 2
- Drop/replace `ansiwrap` dependency; the module is deprecated
- How to display errors?
- 'SelectionMenu' object has no attribute 'text'
- Request user's input does not permit to print a message
- Feature Suggestions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from console-menu.