Move GUI toolkit from tkinter to nicegui for easier prototyping
This commit is contained in:
parent
72878c06e8
commit
f30740fe2d
|
@ -29,6 +29,8 @@ services:
|
||||||
# Provide access to GPU devices
|
# Provide access to GPU devices
|
||||||
- /dev/dri:/dev/dri
|
- /dev/dri:/dev/dri
|
||||||
network_mode: host
|
network_mode: host
|
||||||
|
ports:
|
||||||
|
- 8923:8923
|
||||||
ipc: host
|
ipc: host
|
||||||
#user: "${UID}:${GID}"
|
#user: "${UID}:${GID}"
|
||||||
privileged: true # Allow privileged access if necessary (e.g., for GPU access)
|
privileged: true # Allow privileged access if necessary (e.g., for GPU access)
|
||||||
|
|
|
@ -10,6 +10,10 @@ RUN apt-get -y install qterminal mesa-utils \
|
||||||
gstreamer1.0-plugins-bad \
|
gstreamer1.0-plugins-bad \
|
||||||
gstreamer1.0-plugins-ugly
|
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 /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 /models /ardupilot_gazebo/models
|
||||||
COPY --from=git.spirirobotics.com/spiri/gazebo-resources:main /worlds /ardupilot_gazebo/worlds
|
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
|
COPY ./spawn_drones.sh /spawn_drones.sh
|
||||||
RUN chmod +x /spawn_drones.sh
|
RUN chmod +x /spawn_drones.sh
|
||||||
|
|
||||||
COPY ./launcher.py /launcher.py
|
WORKDIR /app
|
||||||
CMD python3 /launcher.py
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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"
|
|
@ -1,4 +1,4 @@
|
||||||
import tkinter as tk
|
from nicegui import ui
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
# Dictionary of applications: key is the button text, value is the command to execute
|
# 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
|
# Add more applications here if needed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Function to launch an application
|
# Function to launch an application
|
||||||
def launch_app(command):
|
def launch_app(command):
|
||||||
try:
|
try:
|
||||||
subprocess.Popen(command)
|
subprocess.Popen(command)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(
|
print(f"{command[0]} not found. Make sure it's installed and accessible in the PATH.")
|
||||||
f"{command[0]} not found. Make sure it's installed and accessible in the PATH."
|
|
||||||
)
|
|
||||||
|
|
||||||
|
# Create the NiceGUI interface
|
||||||
# Create the main application window
|
ui.label("Spiri Robotics SDK").style('font-size: 20px; margin-bottom: 10px;')
|
||||||
root = tk.Tk()
|
|
||||||
root.title("Spiri SDK Launcher")
|
|
||||||
|
|
||||||
label = tk.Label(root, text="Spiri Robotics SDK", font=("Arial", 14))
|
|
||||||
label.pack(pady=10)
|
|
||||||
|
|
||||||
# Create and place buttons dynamically based on the dictionary
|
# Create and place buttons dynamically based on the dictionary
|
||||||
for app_name, command in applications.items():
|
for app_name, command in applications.items():
|
||||||
button = tk.Button(
|
ui.button(app_name, on_click=lambda cmd=command: launch_app(cmd)).style('width: 150px; height: 50px; margin: 5px;')
|
||||||
root,
|
|
||||||
text=app_name,
|
|
||||||
command=lambda cmd=command: launch_app(cmd),
|
|
||||||
width=20,
|
|
||||||
height=2,
|
|
||||||
)
|
|
||||||
button.pack()
|
|
||||||
|
|
||||||
# Run the Tkinter main loop
|
# Start the NiceGUI application
|
||||||
root.mainloop()
|
ui.run(title="Spiri SDK Launcher", port=8923, dark=None)
|
Loading…
Reference in New Issue