Move GUI toolkit from tkinter to nicegui for easier prototyping #7
|
@ -62,7 +62,7 @@ async def main():
|
||||||
|
|
||||||
ui.separator()
|
ui.separator()
|
||||||
ui.label("Current robots")
|
ui.label("Current robots")
|
||||||
robots_widget = ui.element()
|
robots_widget = ui.element().classes("w-full")
|
||||||
|
|
||||||
#Add a new robot
|
#Add a new robot
|
||||||
with new_robot_widget:
|
with new_robot_widget:
|
||||||
|
|
|
@ -64,23 +64,20 @@ class Robot:
|
||||||
self.processes = []
|
self.processes = []
|
||||||
robots.add(self)
|
robots.add(self)
|
||||||
|
|
||||||
async def async_stop(self):
|
|
||||||
return await run.io_bound(self.stop)
|
|
||||||
|
|
||||||
async def ui(self, element):
|
async def ui(self, element):
|
||||||
adocker = aiodocker.Docker()
|
adocker = aiodocker.Docker()
|
||||||
with element:
|
with element:
|
||||||
robot_ui = ui.element()
|
robot_ui = ui.element().classes("w-full outline p-4")
|
||||||
with robot_ui:
|
with robot_ui:
|
||||||
ui.label(f"{self.robot_type}")
|
ui.label(f"{self.robot_type}")
|
||||||
ui.label(f"""Sysid: {self.sysid}""")
|
ui.label(f"""Sysid: {self.sysid}""")
|
||||||
ui.button("Start", on_click=self.start)
|
ui.button("Start", on_click=self.start).classes("m-2")
|
||||||
ui.button("Stop", on_click=self.async_stop)
|
ui.button("Stop", on_click=self.async_stop).classes("m-2")
|
||||||
async def delete_robot():
|
async def delete_robot():
|
||||||
await self.async_stop()
|
await self.async_stop()
|
||||||
robots.remove(self)
|
robots.remove(self)
|
||||||
element.remove(robot_ui)
|
element.remove(robot_ui)
|
||||||
ui.button("Delete", on_click=delete_robot)
|
ui.button("Delete", on_click=delete_robot).classes("m-2")
|
||||||
docker_elements = {}
|
docker_elements = {}
|
||||||
container_status = {}
|
container_status = {}
|
||||||
while True:
|
while True:
|
||||||
|
@ -105,6 +102,8 @@ class Robot:
|
||||||
docker_elements.pop(container)
|
docker_elements.pop(container)
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
|
async def async_stop(self):
|
||||||
|
return await run.io_bound(self.stop)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
#Signal all processes to stop
|
#Signal all processes to stop
|
||||||
|
|
Loading…
Reference in New Issue