ADD AN IMAGE HERE! [Not adding an image will result in removal]
Then remove these lines.
Download:
Then remove these lines.
Download:
Code:
"""
SENDER MAIL - UI Module
Rich terminal interface with colors and formatting
"""
from rich.console import Console
from rich.table import Table
from rich.panel import Panel
from rich.progress import Progress, SpinnerColumn, BarColumn, TextColumn, TimeElapsedColumn, MofNCompleteColumn
from rich.prompt import Prompt, Confirm
from rich.text import Text
from rich.align import Align
from rich import box
import time
import os
class UI:
def __init__(self):
self.console = Console()
def banner(self):
os.system('clear' if os.name == 'posix' else 'cls')
banner = """
╔══════════════════════════════════════════════════════════════╗
║ ║
║ ███████╗███████╗███╗ ██╗██████╗ ███████╗██████╗ ║
║ ██╔════╝██╔════╝████╗ ██║██╔══██╗██╔════╝██╔══██╗ ║
║ ███████╗█████╗ ██╔██╗ ██║██║ ██║█████╗ ██████╔╝ ║
║ ╚════██║██╔══╝ ██║╚██╗██║██║ ██║██╔══╝ ██╔══██╗ ║
║ ███████║███████╗██║ ╚████║██████╔╝███████╗██║ ██║ ║
║ ╚══════╝╚══════╝╚═╝ ╚═══╝╚═════╝ ╚══════╝╚═╝ ╚═╝ ║
║ ║
║ ███╗ ███╗ █████╗ ██╗██╗ ║
║ ████╗ ████║██╔══██╗██║██║ ║
║ ██╔████╔██║███████║██║██║ ║
║ ██║╚██╔╝██║██╔══██║██║██║ ║
║ ██║ ╚═╝ ██║██║ ██║██║███████╗ ║
║ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚══════╝ ║
║ ║
║ Professional Email Marketing Platform v1.0 ║
║ TurboSMTP · AWS SES · ServerSMTP · Multi-Thread ║
╚══════════════════════════════════════════════════════════════╝
"""
self.console.print(banner, style="bold cyan")
self.console.print(
Align.center("[bold yellow]⚡ High-Performance Email Delivery Engine[/bold yellow]")
)
self.console.print()
def menu(self, title, options, subtitle=None):
"""Display a numbered menu and return choice"""
self.console.print()
panel_content = Text()
if subtitle:
panel_content.append(f" {subtitle}\n\n", style="dim white")
for i, (key, label, icon) in enumerate(options, 1):
panel_content.append(f" [{i}]", style="bold cyan")
panel_content.append(f" {icon} {label}\n", style="white")
self.console.print(Panel(
panel_content,
title=f"[bold yellow]✦ {title} ✦[/bold yellow]",
border_style="cyan",
box=box.DOUBLE_EDGE,
padding=(1, 2)
))
while True:
choice = Prompt.ask(
"[bold cyan] ▶ Select option[/bold cyan]",
console=self.console
)
try:
idx = int(choice) - 1
if 0 <= idx < len(options):
return options[idx][0]
except ValueError:
# Allow direct key input
for key, label, icon in options:
if choice.lower() == key.lower():
return key
self.error("Invalid option. Try again.")
def input(self, prompt, default=None, password=False):
return Prompt.ask(
f"[bold green] ▶ {prompt}[/bold green]",
default=default,
password=password,
console=self.console
)
def confirm(self, prompt):
return Confirm.ask(f"[bold yellow] ? {prompt}[/bold yellow]", console=self.console)
def success(self, msg):
self.console.print(f" [bold green]✔[/bold green] {msg}", style="green")
def error(self, msg):
self.console.print(f" [bold red]✘[/bold red] {msg}", style="red")
def warning(self, msg):
self.console.print(f" [bold yellow]⚠[/bold yellow] {msg}", style="yellow")
def info(self, msg):
self.console.print(f" [bold blue]ℹ[/bold blue] {msg}", style="blue")
def section(self, title):
self.console.print()
self.console.print(f"[bold cyan] ══ {title} ══[/bold cyan]")
self.console.print()
def table(self, title, columns, rows, styles=None):
table = Table(
title=title,
box=box.ROUNDED,
border_style="cyan",
header_style="bold yellow",
title_style="bold white",
show_lines=True
)
for col in columns:
table.add_column(col, style="white")
for row in rows:
if styles:
table.add_row(*[str(c) for c in row], style=styles.get(str(row[0]), "white"))
else:
table.add_row(*[str(c) for c in row])
self.console.print(table)
def progress_bar(self, total, description="Sending"):
return Progress(
SpinnerColumn(style="cyan"),
TextColumn("[bold cyan]{task.description}"),
BarColumn(bar_width=40, style="cyan", complete_style="green"),
MofNCompleteColumn(),
TextColumn("[bold green]{task.percentage:>5.1f}%"),
TimeElapsedColumn(),
console=self.console,
refresh_per_second=10
)
def pause(self, msg="Press Enter to continue..."):
self.console.input(f"\n [dim]{msg}[/dim] ")
def print(self, *args, **kwargs):
self.console.print(*args, **kwargs)