Files

86 lines
2.4 KiB
Python
Raw Permalink Normal View History

#!/usr/bin/env python3
"""
Terminal Launcher - Simple GUI for opening WSL, PowerShell, Ubuntu
Double-click to run on Windows
"""
import tkinter as tk
from tkinter import messagebox
import subprocess
import sys
import os
class TerminalLauncher:
def __init__(self, root):
self.root = root
self.root.title("Terminal Launcher")
self.root.geometry("350x220")
self.root.resizable(False, False)
# Center window on screen
self.root.update_idletasks()
x = (self.root.winfo_screenwidth() // 2) - (self.root.winfo_width() // 2)
y = (self.root.winfo_screenheight() // 2) - (self.root.winfo_height() // 2)
self.root.geometry(f"+{x}+{y}")
# Title
title = tk.Label(root, text="Terminal Launcher", font=("Segoe UI", 16, "bold"))
title.pack(pady=20)
# Buttons
self.btn_wsl = tk.Button(
root,
text="🖥️ WSL (Default)",
width=30,
height=2,
font=("Segoe UI", 11),
command=self.launch_wsl
)
self.btn_wsl.pack(pady=8)
self.btn_powershell = tk.Button(
root,
text="⚡ PowerShell",
width=30,
height=2,
font=("Segoe UI", 11),
command=self.launch_powershell
)
self.btn_powershell.pack(pady=8)
self.btn_ubuntu = tk.Button(
root,
text="🐧 Ubuntu (WSL)",
width=30,
height=2,
font=("Segoe UI", 11),
command=self.launch_ubuntu
)
self.btn_ubuntu.pack(pady=8)
def launch_wsl(self):
try:
subprocess.Popen("wsl", shell=True)
self.root.quit()
except Exception as e:
messagebox.showerror("Error", f"Failed to launch WSL:\n{e}")
def launch_powershell(self):
try:
subprocess.Popen("powershell", shell=True)
self.root.quit()
except Exception as e:
messagebox.showerror("Error", f"Failed to launch PowerShell:\n{e}")
def launch_ubuntu(self):
try:
subprocess.Popen("wsl -d Ubuntu", shell=True)
self.root.quit()
except Exception as e:
messagebox.showerror("Error", f"Failed to launch Ubuntu:\n{e}")
if __name__ == "__main__":
root = tk.Tk()
app = TerminalLauncher(root)
root.mainloop()