Добавлена обработка сигнала выхода из программы
This commit is contained in:
@@ -2,8 +2,11 @@
|
||||
"""
|
||||
Главное меню программы.
|
||||
Загружает проект при старте и предоставляет доступ ко всем подменю.
|
||||
Обрабатывает прерывание Ctrl+C для корректного выхода.
|
||||
"""
|
||||
from core.fs import load_project
|
||||
|
||||
import sys
|
||||
from core.fs import load_project, save_project_partial
|
||||
from editor import editor_menu
|
||||
from plan import plan_menu
|
||||
from response import response_menu
|
||||
@@ -15,33 +18,45 @@ PROJECT_FILE = "project.json"
|
||||
def main():
|
||||
mixture, design, responses = load_project(PROJECT_FILE)
|
||||
|
||||
while True:
|
||||
print("\n" + "=" * 50)
|
||||
print("ГЛАВНОЕ МЕНЮ")
|
||||
print("1. Редактор состава")
|
||||
print("2. Планирование эксперимента")
|
||||
print("3. Ввод значений отклика")
|
||||
print("4. Анализ значений")
|
||||
print("5. Крутое восхождение")
|
||||
print("6. Выход")
|
||||
print("=" * 50)
|
||||
choice = input("Выберите пункт: ").strip()
|
||||
try:
|
||||
while True:
|
||||
print("\n" + "=" * 50)
|
||||
print("ГЛАВНОЕ МЕНЮ")
|
||||
print("1. Редактор состава")
|
||||
print("2. Планирование эксперимента")
|
||||
print("3. Ввод значений отклика")
|
||||
print("4. Анализ значений")
|
||||
print("5. Крутое восхождение")
|
||||
print("6. Выход")
|
||||
print("=" * 50)
|
||||
choice = input("Выберите пункт: ").strip()
|
||||
|
||||
if choice == "6":
|
||||
print("До свидания! (данные не сохранены автоматически)")
|
||||
break
|
||||
elif choice == "1":
|
||||
editor_menu(mixture)
|
||||
elif choice == "2":
|
||||
design = plan_menu(mixture, design)
|
||||
elif choice == "3":
|
||||
responses = response_menu(design, responses)
|
||||
elif choice == "4":
|
||||
analysis_menu(mixture, design, responses)
|
||||
elif choice == "5":
|
||||
ascent_menu(mixture, design, responses)
|
||||
if choice == "6":
|
||||
print("До свидания! (данные не сохранены автоматически)")
|
||||
break
|
||||
elif choice == "1":
|
||||
editor_menu(mixture)
|
||||
elif choice == "2":
|
||||
design = plan_menu(mixture, design)
|
||||
elif choice == "3":
|
||||
responses = response_menu(design, responses)
|
||||
elif choice == "4":
|
||||
analysis_menu(mixture, design, responses)
|
||||
elif choice == "5":
|
||||
ascent_menu(mixture, design, responses)
|
||||
else:
|
||||
print("Неверный пункт.")
|
||||
except KeyboardInterrupt:
|
||||
print("\n\nОбнаружено прерывание (Ctrl+C).")
|
||||
# Спрашиваем, хочет ли пользователь сохранить текущий проект
|
||||
save_choice = input("Сохранить текущий проект перед выходом? (y/n, Enter = нет): ").strip().lower()
|
||||
if save_choice == 'y':
|
||||
save_project_partial(PROJECT_FILE, mixture, design, responses)
|
||||
print("Проект сохранён.")
|
||||
else:
|
||||
print("Неверный пункт.")
|
||||
print("Выход без сохранения.")
|
||||
print("До свидания!")
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user