import tkinter as tk
from tkinter import messagebox, filedialog
import os
import subprocess
# Global variable to store the game executable path
game_path = ""
# Function to launch the game
def launch_game():
global game_path
if game_path and os.path.exists(game_path):
try:
subprocess.run([game_path], check=True)
except subprocess.CalledProcessError as e:
messagebox.showerror("Error", f"Failed to launch the game: {e}")
else:
messagebox.showerror("Error", "Game executable not found! Please select a
valid file.")
# Function to check for updates (placeholder logic)
def check_for_updates():
messagebox.showinfo("Update Check", "No updates available.")
# Function to exit the launcher
def exit_launcher():
root.quit()
# Function to browse and select the game executable
def browse_exe():
global game_path
game_path = filedialog.askopenfilename(
title="Select Game Executable",
filetypes=(("Executable files", "*.exe"), ("All files", "*.*")),
initialdir=os.path.expanduser("~")
)
if game_path:
exe_label.config(text=f"Selected: {game_path}")
# Create the main window
root = tk.Tk()
root.title("Game Launcher")
root.geometry("640x720")
# Load the background image
background_image = tk.PhotoImage(file=r"path\to\your\background.png") # Update
with your image path
background_label = tk.Label(root, image=background_image)
background_label.place(relwidth=1, relheight=1) # Make the image fill the window
# UI Elements
title_label = tk.Label(root, text="rekts launcher", font=("Arial", 18), bg="blue",
fg="black")
title_label.pack(pady=20)
# Play Game Button
play_button = tk.Button(root, text="Play TTW Online", font=("Arial", 14),
command=launch_game)
play_button.pack(pady=10)
# Check for Updates Button
update_button = tk.Button(root, text="Check for Updates", font=("Arial", 14),
command=check_for_updates)
update_button.pack(pady=10)
# Browse for .exe Button
browse_button = tk.Button(root, text="Browse for .exe", font=("Arial", 14),
command=browse_exe)
browse_button.pack(pady=10)
# Label to show the selected executable path
exe_label = tk.Label(root, text="No executable selected", font=("Arial", 12),
bg="black", fg="white")
exe_label.pack(pady=10)
# Exit Button
exit_button = tk.Button(root, text="Exit", font=("Arial", 14),
command=exit_launcher)
exit_button.pack(pady=10)
# Run the application
root.mainloop()