from imgui_bundle import imgui, imgui_ctx from model import * class ClassEditor: def __init__(self): super().__init__() self.add_name = str() self.select = 0 def __call__(self): classes = Class.select() with imgui_ctx.begin("Class Editor"): imgui.text("Add Class") _, self.add_name = imgui.input_text(" ", self.add_name) if imgui.button("Add"): if self.add_name: Class.create(name=self.add_name) self.add_name = str() imgui.separator() if not classes: imgui.text("No Dataset could be queried") return for n, c in enumerate(classes, start=1): display = f"{n}. {c.name}" opened, _ = imgui.selectable(display, self.select == n-1) if opened: self.select = n-1 return classes[self.select]