Move GUI toolkit from tkinter to nicegui for easier prototyping

This commit is contained in:
Alex Davies 2024-11-05 10:29:34 -04:00
parent 72878c06e8
commit f30740fe2d
6 changed files with 2074 additions and 24 deletions

View File

@ -29,6 +29,8 @@ services:
# Provide access to GPU devices
- /dev/dri:/dev/dri
network_mode: host
ports:
- 8923:8923
ipc: host
#user: "${UID}:${GID}"
privileged: true # Allow privileged access if necessary (e.g., for GPU access)

View File

@ -10,6 +10,10 @@ RUN apt-get -y install qterminal mesa-utils \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly
#Install poetry
RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH="/root/.local/bin:$PATH"
COPY --from=git.spirirobotics.com/spiri/gazebo-resources:main /plugins /ardupilot_gazebo/plugins
COPY --from=git.spirirobotics.com/spiri/gazebo-resources:main /models /ardupilot_gazebo/models
COPY --from=git.spirirobotics.com/spiri/gazebo-resources:main /worlds /ardupilot_gazebo/worlds
@ -20,8 +24,16 @@ ENV GZ_SIM_RESOURCE_PATH=/ardupilot_gazebo/models:/ardupilot_gazebo/worlds
COPY ./spawn_drones.sh /spawn_drones.sh
RUN chmod +x /spawn_drones.sh
COPY ./launcher.py /launcher.py
CMD python3 /launcher.py
WORKDIR /app
COPY ./pyproject.toml /app/pyproject.toml
COPY ./poetry.lock /app/poetry.lock
RUN poetry install --no-root
COPY ./spiri_sdk_guitools /app/spiri_sdk_guitools
CMD poetry run python3 spiri_sdk_guitools/launcher.py

0
guiTools/README.md Normal file
View File

2035
guiTools/poetry.lock generated Normal file

File diff suppressed because it is too large Load Diff

16
guiTools/pyproject.toml Normal file
View File

@ -0,0 +1,16 @@
[tool.poetry]
name = "spiri-sdk-guitools"
version = "0.1.0"
description = ""
authors = ["Alex Davies <traverse.da@gmail.com>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.11"
nicegui = "^2.5.0"
pywebview = "^5.3.2"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

View File

@ -1,4 +1,4 @@
import tkinter as tk
from nicegui import ui
import subprocess
# Dictionary of applications: key is the button text, value is the command to execute
@ -11,34 +11,19 @@ applications = {
# 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."
)
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")
label = tk.Label(root, text="Spiri Robotics SDK", font=("Arial", 14))
label.pack(pady=10)
# Create the NiceGUI interface
ui.label("Spiri Robotics SDK").style('font-size: 20px; margin-bottom: 10px;')
# 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()
ui.button(app_name, on_click=lambda cmd=command: launch_app(cmd)).style('width: 150px; height: 50px; margin: 5px;')
# Run the Tkinter main loop
root.mainloop()
# Start the NiceGUI application
ui.run(title="Spiri SDK Launcher", port=8923, dark=None)