enhance the following code to have a graphical inteface: import datetime import psutil…
- User
enhance the following code to have a graphical inteface: import datetime import psutil import threading from colorama import Fore, Style import shutil import time import os from tabulate import tabulate import random import string import math Vir = "0.0.2*alpha"
skiploading = False if os.name in ["nt", "dos"]: USER = str(os.getlogin()) elif os.name in ["posix"]: USER = str(os.environ.get("REPL_OWNER")) else: USER = str(os.environ.get("USERNAME")) if USER == "None": USER = str(os.path.expanduser("~")) if USER == "None": USER = "User" def show_loading_screen(): print(Fore.GREEN + Style.BRIGHT + f"Welcome To Maco ~ Terminal [ {Fore.MAGENTA}{USER}{Fore.GREEN} ]") width = 40 total = 100 interval = total / width for i in range(width + 1): progress = int(i * interval) bar = '█' * i stars = '=' * (width - i) loading_text = f"[{bar}{stars}] {progress}%" print(Fore.CYAN + loading_text, end='\r') time.sleep(0.1) print(Style.RESET_ALL)
if not skiploading: show_loading_screen() current_datetime = datetime.datetime.now() day = current_datetime.isoweekday()
if day == 1: day = "Monday" elif day == 2: day = "Tuesday" elif day == 3: day = "Wednesday" elif day == 4: day = "Thursday" elif day == 5: day = "Friday" elif day == 6: day = "Saturday" elif day == 7: day = "Sunday" os.system('clear') acv = os.getcwd() id=''.join(random.choices(string.ascii_letters + string.digits, k=5)) current_datetime = datetime.datetime.now() date_string = current_datetime.strftime("%d/%m/%Y") print(f"{Fore.MAGENTA}Run_id: {Fore.CYAN}{id}{Fore.MAGENTA} Version: {Fore.CYAN}{Vir} {Fore.MAGENTA}Date: {Fore.CYAN}{day} / {date_string}")
def handle_input(): while True: user_input = input(f"{Fore.MAGENTA}@{USER}{os.getcwd()}:{Fore.GREEN}~$ ") if not user_input: continue X, *args = user_input.split() if X == 'kill': print(Fore.RED + 'This Process has been Terminated') break elif X in ['clear', 'cls']: os.system("clear") current_datetime = datetime.datetime.now() date_string = current_datetime.strftime("%d/%m/%Y") print(f"{Fore.MAGENTA}Run_id: {Fore.CYAN}{id}{Fore.MAGENTA} Version: {Fore.CYAN}{Vir} {Fore.MAGENTA}Date: {Fore.CYAN}{day} / {date_string}") elif X in ['help']: print(""" kill: Exits the shell. clear or cls: Clears the terminal screen. help: Displays a help message with a list of available commands. cd [directory]: Changes the current directory to the specified directory. ls: Lists the files and directories in the current directory. edit [filename]: Opens the specified file in the default editor for editing. write [filename]: Appends text to the specified file and allows you to create multiple lines and create text files(type 'exit' to stop). run [filetype][filename]: Executes the specified file with support of (python). cat [filename]: Displays the contents of the specified file. timer [seconds]: Sets a timer for the specified number of seconds. cp [source] [destination]: Copies a file from the source location to the destination location. mv [source] [destination]: Moves or renames a file from the source location to the destination location. rm [filename]: Deletes a file. mkdir [directory]: Creates a new directory. rmdir [directory]: Removes a directory (if it's empty). howdoi [query]: Assists with coding, and provides snippets of code. disk: Displays information about the disk usage. cpu: Displays information about the CPU usage. """) elif X in ['cd', '..']: if X == 'cd': if not args: print(Fore.RED + "Error: Missing directory name" + Style.RESET_ALL) continue try: res = os.chdir(args[0]) print(f"Changed directory to {res}")
- Assistant
- User
provide the full code for ease of use
- Assistant
Certainly! Here's the full code with the graphical interface:
import datetime import psutil import threading from colorama import Fore, Style import shutil import time import os from tabulate import tabulate import random import string import math from tkinter import Tk, Frame, Label, Entry, Button, Text, Scrollbar, RIGHT, Y, END Vir = "0.0.2*alpha" skiploading = False if os.name in ["nt", "dos"]: USER = str(os.getlogin()) elif os.name in ["posix"]: USER = str(os.environ.get("REPL_OWNER")) else: USER = str(os.environ.get("USERNAME")) if USER == "None": USER = str(os.path.expanduser("~")) if USER == "None": USER = "User" def show_loading_screen(): loading_text.configure(text="Welcome To Maco ~ Terminal [ {} ]".format(USER)) width =