import os import platform from colorama import Fore, Style from Assets.ascii_text_prompts import ascii_art, full_ascii_art, infinitei from Assets.random_tip import get_random_tip_with_color from Modules.global_commands import * def clear_screen(): # Check the system platform and use the appropriate command if platform.system().lower() == "windows": os.system('cls') # Windows command to clear the screen else: os.system('clear') # Unix-based (Linux/macOS) command to clear the screen def header(is_main_menu=False): """ Displays the header with optional full application details. :param is_main_menu: Boolean to indicate whether to display full details. """ clear_screen() if is_main_menu: print(center_text(full_ascii_art)) # Full application name in ASCII art print(center_text(infinitei)) # "Created By Me" else: print(center_text(ascii_art)) # Minimal header print(center_text(get_random_tip_with_color()) + "\n") def display_menu(menu_options): while True: header(is_main_menu=True) # Show full details on main menu for key, value in menu_options.items(): print(f"[{key}] {value['name'].upper()}") print("[0] Logout") print("[NOTE] Analyst Notebook | [ABOUT] About Page\n") # Add global command options choice = input("Enter your choice: ").strip().lower() # Handle global commands if choice in ["note", "about"]: global_command_handler(choice) # Call the global command handler continue # Restart the loop after handling global commands # Match the choice to a menu option if choice in menu_options: menu_options[choice]["submenu"]() # Call the submenu without arguments elif choice in ["0", "q", "exit", "quit"]: print("Logging out...") break else: print("Invalid choice. Please try again.") def print_info(title, content): header() print("=" * 40) print(f"{title.center(40)}") print("=" * 40) print(content) input("\nPress Enter to return to the menu...") def center_text(text): terminal_width = os.get_terminal_size().columns centered_lines = [] for line in text.splitlines(): centered_lines.append(line.center(terminal_width)) return "\n".join(centered_lines)