シンプルなディープ メニュー システムを作成しています。これまでのところ、最初のメニュー システムよりも深いところで (つまり、メイン メニューでタスク 1 またはタスク 2 を選択した後) '0' をヒットしない限り、すべて正常に動作します。タスク 1 とタスク 2 よりも。
私の質問は次のとおりです。これを修正するにはどうすればよいですか。また、これは効率的なメニュー システムですか? (説明するために「# コメント」行をさらに追加する必要があるとしても。)
# Multitasker - Deep Menu System
# A Menu that Allows the User to Select Tasks, Subtasks and Deeper Subtasks
# This is the initial screen.
def homescreen():
print("""
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X MULTITASKER - DEEP MENU SYSTEM X
X X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X READY TO START? X
X --------------------- X
X PRESS THE 'ENTER' X
X KEY TO BEGIN! X
X --------------------- X
X X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""",end=" ")
def task1():
task1 = None
while task1 != "0":
print(
"""
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X MULTITASKER - DEEP MENU SYSTEM X
X X
XXXX TASK OPTIONS XXXXXXXXXXXXXXXXXXXXXXXX
X X
X ---------------------------------- X
X 1 - SUBTASK 1 X
X 2 - BACK X
X ---------------------------------- X
X 0 - Quit X
X X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""", end=" ")
task1 = input("\n\t\tPick a Choice Between 0-2:\t#")
print()
# Exit
if task1 == ('0'):
homescreen()
input(" ")
menu = None
elif task1 == ('1'):
subtask1()
elif task1 == ('2'):
return
else:
notatask()
def subtask1():
subtask1 = None
while subtask1 != "0":
print(
"""
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X MULTITASKER - DEEP MENU SYSTEM X
X X
XXXX TASK OPTIONS XXXXXXXXXXXXXXXXXXXXXXXX
X X
X ---------------------------------- X
X 1 - DEEP SUBTASK 1 X
X 2 - BACK X
X ---------------------------------- X
X 0 - Quit X
X X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""", end=" ")
subtask1 = input("\n\t\tPick a Choice Between 0-2:\t#")
print()
# Exit
if subtask1 == ('0'):
homescreen()
input(" ")
menu = None
elif subtask1 == ('1'):
deepsubtask1()
elif subtask1 == ('2'):
return
else:
notatask()
def deepsubtask1():
print("""
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X THIS IS DEEP SUBTASK 1 X
X X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
PRESS 'ENTER' TO RETURN!
""", end=" ")
input(" ")
# TASK 2
def task2():
task2 = None
while task2 != "0":
print(
"""
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X MULTITASKER - DEEP MENU SYSTEM X
X X
XXXX TASK OPTIONS XXXXXXXXXXXXXXXXXXXXXXXX
X X
X ---------------------------------- X
X 1 - SUBTASK 2 X
X 2 - BACK X
X ---------------------------------- X
X 0 - Quit X
X X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""", end=" ")
task2 = input("\n\t\tPick a Choice Between 0-2:\t#")
print()
# Exit
if task2 == ('0'):
homescreen()
input(" ")
menu = None
elif task2 == ('1'):
subtask2()
elif task2 == ('2'):
return
else:
notatask()
def subtask2():
subtask2 = None
while subtask2 != "0":
print(
"""
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X MULTITASKER - DEEP MENU SYSTEM X
X X
XXXX TASK OPTIONS XXXXXXXXXXXXXXXXXXXXXXXX
X X
X ---------------------------------- X
X 1 - DEEP SUBTASK 2 X
X 2 - BACK X
X ---------------------------------- X
X 0 - Quit X
X X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""", end=" ")
subtask2 = input("\n\t\tPick a Choice Between 0-2:\t#")
print()
# Exit
if subtask2 == ('0'):
homescreen()
input(" ")
menu = None
elif subtask2 == ('1'):
deepsubtask2()
elif subtask2 == ('2'):
return
else:
notatask()
def deepsubtask2():
print("""
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X THIS IS DEEP SUBTASK 2 X
X X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
PRESS 'ENTER' TO RETURN!
""", end=" ")
input(" ")
# Errors
def notatask():
print("", end=" ")
def final():
print("No More Tasks!")
# Makes choice equal to no actual selection or choice
homescreen()
menu = None
input(" ")
# Start the Main Menu
while menu != "0":
print(
"""
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X MULTITASKER - DEEP MENU SYSTEM X
X X
XXXX TASK OPTIONS XXXXXXXXXXXXXXXXXXXXXXXX
X X
X ---------------------------------- X
X 1 - TASK 1 X
X 2 - TASK 2 X
X ---------------------------------- X
X 0 - Quit X
X X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""", end=" ")
menu = input("\n\t\tPick a Choice Between 0-2:\t#")
print()
# Exit
if menu == ('0'):
print("""
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X MULTITASKER - DEEP MENU SYSTEM X
X X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
X X
X READY TO START? X
X --------------------- X
X PRESS THE 'ENTER' X
X KEY TO BEGIN! X
X --------------------- X
X X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
""",end=" ")
input(" ")
menu()
elif menu == ('1'):
task1()
elif menu == ('2'):
task2()
else:
notatask()