spiri-sdk/guiTools/launcher.py

37 lines
1.1 KiB
Python
Raw Normal View History

import tkinter as tk
import subprocess
# Dictionary of applications: key is the button text, value is the command to execute
applications = {
2024-10-16 09:13:46 -03:00
"Terminal": ['qterminal'],
"rqt": ["rqt"],
"rviz2": ["rviz2"],
"Gazebo": "gz sim -v4 -g".split(),
"Gazebo Standalone": "gz sim -v4".split(),
"glxgears (GPU test)": ["glxgears"],
# Add more applications here if needed
}
# Function to launch an application
def launch_app(command):
try:
subprocess.Popen(command)
except FileNotFoundError:
print(f"{command[0]} not found. Make sure it's installed and accessible in the PATH.")
# Create the main application window
root = tk.Tk()
root.title("Spiri SDK Launcher")
2024-09-19 14:33:29 -03:00
label = tk.Label(root, text="Spiri Robotics SDK", font=("Arial", 14))
label.pack(pady=10)
# Create and place buttons dynamically based on the dictionary
for app_name, command in applications.items():
button = tk.Button(root, text=app_name, command=lambda cmd=command: launch_app(cmd), width=20, height=2)
button.pack()
# Run the Tkinter main loop
root.mainloop()