Advertisement
afrizalwahyuadi66

UMenu.py

Apr 10th, 2024
873
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.93 KB | Source Code | 0 0
  1. # UMenu.py
  2.  
  3. # Perpustakaan----------------
  4. import os
  5. from subprocess import call
  6. import shutil
  7. #-----------------------------
  8.  
  9.  
  10. # Function to print colored text---------------
  11. def print_color(text, color):
  12.     if color == 'red':
  13.         print("\033[91m" + text + "\033[00m")
  14.     elif color == 'green':
  15.         print("\033[92m" + text + "\033[00m")
  16.     elif color == 'yellow':
  17.         print("\033[93m" + text + "\033[00m")
  18.     elif color == 'blue':
  19.         print("\033[94m" + text + "\033[00m")
  20.     else:
  21.         print(text)
  22. #---------------------------------------------
  23.  
  24.  
  25. # Define the logo-----------------------------------------------------------------------
  26. logo = (
  27.     "\033[34m  ██╗░░░██╗████████╗░██████╗░░░░░░░█████╗░███╗░░██╗░██████╗███████╗ \n"
  28.     "\033[34m  ██║░░░██║╚══██╔══╝██╔════╝░░░░░░██╔══██╗████╗░██║██╔════╝╚════██║ \n"
  29.     "\033[34m  ██║░░░██║░░░██║░░░╚█████╗░█████╗███████║██╔██╗██║╚█████╗░░░░░██╔╝ \n"
  30.     "\033[34m  ██║░░░██║░░░██║░░░░╚═══██╗╚════╝██╔══██║██║╚████║░╚═══██╗░░░██╔╝░ \n"
  31.     "\033[34m  ██║░░░██║░░░██║░░░░╚═══██╗╚════╝██╔══██║██║╚████║░╚═══██╗░░░██╔╝░ \n"
  32.     "\033[34m  ╚██████╔╝░░░██║░░░██████╔╝░░░░░░██║░░██║██║░╚███║██████╔╝░░██╔╝░░ \n"
  33.     "\033[34m  ░╚═════╝░░░░╚═╝░░░╚═════╝░░░░░░░╚═╝░░╚═╝╚═╝░░╚══╝╚═════╝░░░╚═╝░░░ \n\n"
  34.     "\033               Tugas UTS Algoritma 2\n\n"
  35.                                                                                                                                                                      
  36.     "\033   [91m 1. Afrizal Wahyu Adi Putra\t 11230070\n"
  37.     "\033    2. Nadia Zahira Sofa\t\t 11230056 \n"
  38.     "\033          3. Syifa Susila Pratami\t 11230068 \n"
  39.     "\033[0m"
  40. )
  41. #---------------------------------------------------------------------------------------
  42.  
  43.  
  44. # Clear screen------------------------------------
  45. os.system('cls' if os.name == 'nt' else 'clear')
  46. #-------------------------------------------------
  47.  
  48.  
  49. # Print the logo---------
  50. print(logo)
  51. #------------------------
  52.  
  53. #Menampilkan Menu----------------------------
  54. def show_menu():
  55.     print("=== Menu Program ===")
  56.     print("| 1. Program 1     |")
  57.     print("| 2. Program 2     |")
  58.     print("| 3. Program 3     |")
  59.     print("| 4. Program 4     |")
  60.     print("| 5. Program 5     |")
  61.     print("| 6  Program 6     |")
  62.     print("| 7. Program 7     |")
  63.     print("| 8. Program 8     |")
  64.     print("| 9. Program 9     |")
  65.     print("| 10. Program 10   |")
  66.     print("====================")
  67. #--------------------------------------------
  68.  
  69. #--------------------------------------------------------------------------------------------
  70. def run_program(program_number):
  71.     program_path = os.path.join(os.path.dirname(__file__), f"UProblem.py {program_number}")
  72.     os.system(f"python {program_path}")
  73.  
  74. if __name__ == "__main__":
  75.     show_menu()
  76.     choice = int(input("Pilih program (1-10): "))
  77.     if 1 <= choice <= 10:
  78.         run_program(choice)
  79.     else:
  80.         print("Pilihan tidak valid.")
  81. #--------------------------------------------------------------------------------------------
  82.  
Tags: sc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement