Skip to content

Commit 4ad2e81

Browse files
committed
Readme updated
1 parent 36a7d5b commit 4ad2e81

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

README.md

+50
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,52 @@
11
# ConsoleMenu
22
A simple console menu for Python3.x scripts
3+
4+
## How to
5+
All you need to do is to use dictionaries to define the structure of your menu.
6+
You're able to use functions and other menus as items, so you can build an infinitive nested menu.
7+
Then call **execute** method and that's it!
8+
9+
```python
10+
import consolemenu
11+
12+
def func1():
13+
# Your code here
14+
15+
def func2():
16+
# Your code here
17+
18+
def func3():
19+
# Your code here
20+
21+
nested_menu = ConsoleMenu(
22+
"Sample nested menu",
23+
{
24+
"call func1": func1,
25+
"call func2": func2,
26+
"call func3": func3,
27+
}
28+
)
29+
30+
menu = ConsoleMenu(
31+
"Sample menu",
32+
{
33+
"call func1": func1,
34+
"call func2": func2,
35+
"call func3": func3,
36+
"goto nested menu": nested_menu,
37+
}
38+
)
39+
40+
menu.execute()
41+
```
42+
43+
The output will be:
44+
```
45+
Sample menu
46+
1) call func1
47+
2) call func2
48+
3) call func3
49+
4) goto nested menu
50+
5) exit
51+
run:
52+
```

0 commit comments

Comments
 (0)