51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
# coding: utf8
|
|
from clihelper import CliHelper, request_input
|
|
|
|
|
|
def open_file():
|
|
print("File Opened")
|
|
|
|
|
|
def new_folder(name):
|
|
print(f"Folder [{name}] created")
|
|
|
|
|
|
def test_helper():
|
|
# c = CliHelper(right_padding=20, draw_menu_again=False)
|
|
# n = c.add_option(title="New")
|
|
# c.add_option(title="Open File", exec_func=open_file)
|
|
# c.add_option(title="Save")
|
|
# c.add_exit_option()
|
|
#
|
|
# c.add_return_option(n)
|
|
# c.add_option(n, "New File")
|
|
# c.add_option(n, "New Folder", new_folder, ("Temp",))
|
|
# c.add_exit_option(n)
|
|
#
|
|
# c.start_loop()
|
|
ch = CliHelper()
|
|
n = ch.add_option("New")
|
|
n.add_return_option()
|
|
n.add_option("New File")
|
|
n.add_option("New Folder", new_folder, ("Temp", ))
|
|
n.add_exit_option()
|
|
|
|
ch.add_option("Open File", open_file)
|
|
ch.add_option("Save")
|
|
ch.add_exit_option()
|
|
|
|
ch.start_loop()
|
|
# n.start_loop()
|
|
|
|
|
|
def test_req():
|
|
v = request_input("\nEnter a number", check_func=lambda x: x.isdigit() and 1 < int(x) < 10, ask_again=False,
|
|
has_default_val=True, default_val="4",
|
|
need_confirm=True)
|
|
print(v)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
# test_req()
|
|
test_helper()
|