2024-11-05 10:29:34 -04:00
|
|
|
from nicegui import ui
|
2024-09-19 14:14:07 -03:00
|
|
|
import subprocess
|
|
|
|
|
|
|
|
# Dictionary of applications: key is the button text, value is the command to execute
|
|
|
|
applications = {
|
2024-11-05 11:22:15 -04:00
|
|
|
"Terminal": ["qterminal"],
|
|
|
|
"rqt": ["rqt"],
|
|
|
|
"rviz2": ["rviz2"],
|
|
|
|
"Gazebo": ["/spawn_drones.sh"],
|
|
|
|
"Gazebo Standalone": "gz sim -v4".split(),
|
2024-09-19 14:14:07 -03:00
|
|
|
# Add more applications here if needed
|
|
|
|
}
|
|
|
|
|
|
|
|
# Function to launch an application
|
|
|
|
def launch_app(command):
|
|
|
|
try:
|
|
|
|
subprocess.Popen(command)
|
|
|
|
except FileNotFoundError:
|
2024-11-05 10:29:34 -04:00
|
|
|
print(f"{command[0]} not found. Make sure it's installed and accessible in the PATH.")
|
2024-09-19 14:14:07 -03:00
|
|
|
|
2024-11-05 10:29:34 -04:00
|
|
|
# Create the NiceGUI interface
|
2024-11-05 11:22:15 -04:00
|
|
|
ui.label("Spiri Robotics SDK").style('font-size: 40px; margin-bottom: 10px;').classes('w-full text-center')
|
2024-09-19 14:33:29 -03:00
|
|
|
|
2024-09-19 14:14:07 -03:00
|
|
|
|
2024-11-05 11:22:15 -04:00
|
|
|
with ui.tabs().classes('w-full') as tabs:
|
|
|
|
tab_tools = ui.tab('Tools')
|
|
|
|
tab_robots = ui.tab('Robots')
|
|
|
|
# two = ui.tab('Two')
|
|
|
|
with ui.tab_panels(tabs, value=tab_tools).classes():
|
|
|
|
with ui.tab_panel(tab_tools):
|
|
|
|
# Create and place buttons dynamically based on the dictionary
|
|
|
|
with ui.grid(columns=3):
|
|
|
|
for app_name, command in applications.items():
|
|
|
|
ui.button(app_name, on_click=lambda cmd=command: launch_app(cmd)).style('width: 150px; height: 50px; margin: 5px;')
|
|
|
|
with ui.tab_panel(tab_robots):
|
|
|
|
with ui.card().tight():
|
|
|
|
ui.label(f"Robots SysID")
|
2024-11-05 10:29:34 -04:00
|
|
|
# Start the NiceGUI application
|
|
|
|
ui.run(title="Spiri SDK Launcher", port=8923, dark=None)
|