Skip to content

Commit

Permalink
fix: Change Terminal Command Output Format to Align with Vite-Style O…
Browse files Browse the repository at this point in the history
…utput | closes #22

Simple shit, just changed those print commands ; )
  • Loading branch information
iamDyeus committed Nov 19, 2024
1 parent 58c9428 commit cfec979
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
15 changes: 8 additions & 7 deletions tkreload/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@

def show_help(auto_reload):
"""Displays help commands with detailed info and rich formatting."""
console.print("\n[bold yellow]Tkreload Help:[/bold yellow]")
console.print("[bold blue]-----------------------------------------[/bold blue]")
console.print("[bold cyan]Enter + H[/bold cyan] : Display this help section.")
console.print("[bold cyan]Enter + R[/bold cyan] : Restart the Tkinter app.")
console.print("[bold cyan]Enter + A[/bold cyan] : Toggle auto-reload (currently [bold magenta]{}[/bold magenta]).".format("Enabled" if auto_reload else "Disabled"))
console.print("[bold red]Ctrl + C[/bold red] : Exit the development server.")
console.print("[bold blue]-----------------------------------------[/bold blue]\n")
console.print("\n[bold yellow]Tkreload Help:[/bold yellow] [dim](detailed command info)[/dim]\n")
console.print("[bold cyan]→[/bold cyan] [bold white]Press H[/bold white] : Display this help section.")
console.print("[bold cyan]→[/bold cyan] [bold white]Press R[/bold white] : Restart the Tkinter app.")
console.print(
f"[bold cyan]→[/bold cyan] [bold white]Press A[/bold white] : Toggle auto-reload "
f"(currently [bold magenta]{auto_reload}[/bold magenta])."
)
console.print("[bold cyan]→[/bold cyan] [bold white]Ctrl + C[/bold white] : Exit the development server.\n")
14 changes: 9 additions & 5 deletions tkreload/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self, app_file):
self.process = None
self.observer = None
self.reload_count = 0
self.startup_time=0

def run_tkinter_app(self):
"""Run the given Tkinter app."""
Expand Down Expand Up @@ -65,18 +66,21 @@ def restart_app(self):

def start(self):
"""Starts the application, including monitoring and handling commands."""
start_time = time.time() # Record the start time
self.run_tkinter_app()
self.monitor_file_changes(self.restart_app)
self.startup_time = (time.time() - start_time) * 1000 # Calculate startup time in milliseconds

try:
self.console.print(
"\n\n\t[bold cyan]Tkreload[/bold cyan] [bold blue]is running ✅\n\t[/bold blue]- Press [bold cyan]H[/bold cyan] for help,\n\t[bold cyan]- R[/bold cyan] to restart,\n\t[bold cyan]- A[/bold cyan] to toggle auto-reload (currently [bold magenta]{}[/bold magenta]),\n\t[bold red]- Ctrl + C[/bold red] to exit.".format(
"Disabled"
if not self.auto_reload_manager.get_status()
else "Enabled"
)
f"\n[bold white]Tkreload[/bold white] [dim](ready in {self.startup_time:.2f} ms)[/dim]\n"
f"\t[bold cyan]→[/bold cyan] [bold white]Auto-reload:[/bold white] [bold magenta]{'Enabled' if self.auto_reload_manager.get_status() else 'Disabled'}[/bold magenta]\n"
"\t[bold cyan]→[/bold cyan] [bold white]Help:[/bold white] Press [bold cyan]H[/bold cyan]\n"
"\t[bold cyan]→[/bold cyan] [bold white]Restart:[/bold white] Press [bold cyan]R[/bold cyan]\n"
"\t[bold cyan]→[/bold cyan] [bold white]Exit:[/bold white] Press [bold red]Ctrl + C[/bold red]"
)


while True:
if platform.system() == "Windows":
if msvcrt.kbhit(): # Check for keyboard input (Windows only)
Expand Down

0 comments on commit cfec979

Please sign in to comment.