-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated docs, can now specify title in dict to be passed to meny.menu…
…, refactor
- Loading branch information
Showing
10 changed files
with
298 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from random import randint | ||
from time import sleep | ||
import meny | ||
|
||
meny.set_default_frontend("simple") | ||
|
||
@meny.title("FizzBuzz!") | ||
def fizzbuzz(): | ||
for i in range(21): | ||
stringy = '' | ||
|
||
fizz = i % 3 == 0 | ||
buzz = i % 5 == 0 | ||
|
||
if fizz: | ||
stringy = stringy + 'Fizz' | ||
if buzz: | ||
stringy = stringy + 'Buzz' | ||
if not (fizz or buzz): | ||
stringy = i | ||
|
||
print(stringy) | ||
sleep(0.1) | ||
|
||
@meny.title("Get random integer") | ||
def random_integer(): | ||
print(randint(0,9)) | ||
sleep(1) | ||
|
||
def add_ints(a, b): | ||
print(a+b) | ||
sleep(1) | ||
|
||
def append_strings(a, b): | ||
print(a+b) | ||
sleep(1) | ||
|
||
# Type hints won't interfere with meny, and will actually be displayed when using the fancy frontend | ||
@meny.title("Print elements and their types") | ||
def print_types_in_list(a: list): | ||
[print(f'Element {i}: {elem}, type: {type(elem)}') for i, elem in enumerate(a)] | ||
sleep(1) | ||
|
||
|
||
def programmatic_args(a, b, c, d): | ||
print(a, b, c, d) | ||
sleep(1) | ||
|
||
case_args = {programmatic_args: (1, 2)} | ||
case_kwargs = {programmatic_args: {"d": 4, "c": 3}} | ||
meny.menu(locals(), title=' Main menu ', case_args=case_args, case_kwargs=case_kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .menu import cng as config | ||
from .menu import menu, Menu | ||
from .decorators import case, ignore | ||
from .utils import clear_screen, input_splitter, list_local_cases, set_default_frontend | ||
from .decorators import title, ignore | ||
from .utils import clear_screen, input_splitter, set_default_frontend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.