Example #1
0
 def render(self):
     with simple.group(
         self.group, parent=f"cattasks{self.category_id}"
     ):
         dpg.add_indent()
         dpg.add_checkbox(
             self.id,
             label=self.label,
             default_value=self.complete,
             callback=self.checkbox_check,
         )
         dpg.add_same_line(spacing=10)
         dpg.add_button(
             f"up{self.id}",
             arrow=True,
             direction=2,
             callback=self.move_task_up,
             callback_data={"item": self.group}
         )
         dpg.add_same_line()
         dpg.add_button(
             f"down{self.id}",
             arrow=True,
             direction=3,
             callback=self.move_task_down,
             callback_data={"item": self.group}
         )
         dpg.unindent()
Example #2
0
    def _build(self):
        with simple.window(f"Object Pool: {self._title}", width=600, height=400, x_pos=0, y_pos=0, on_close=self.destroy, no_resize=False, no_close=True, no_move=True, no_collapse=True):
            core.add_label_text("Pools##total", label="Total Pools", default_value=str(len(self._pools)))
            core.add_label_text("Pools##memory", label="Memory Usage (MB)", default_value="0")
            core.add_label_text("Pools##cpu", label="System Load (%)", default_value="0")
            
            # show all pools
            for pool_name, pool in self._pools.items():
                with simple.collapsing_header(f"Pool: {pool_name}", default_open=False):
                    core.add_label_text(f"Objects_{pool_name}##total", label="Total Objects", default_value="0 / inf")
                    core.add_label_text(f"Objects_{pool_name}##subscribers", label="Subscriptions", default_value="0")
                    core.add_indent()
                    with simple.collapsing_header(f"Objects_{pool_name}##table", default_open=True):
                        pass
                    core.unindent()

        core.set_render_callback(self._render_callback)
        core.set_main_window_size(600, 400)
        core.set_main_window_title("Object Pool UI")
Example #3
0
    def submit_category(self, sender, data):
        if data:
            category_label = data["label"]
            category_color = data["color"]
        else:
            parent = dpg.get_item_parent(sender)
            input_id = parent.replace("newcategory", "")
            category_label = dpg.get_value(f"catlabel{input_id}")
            category_color = dpg.get_value(f"catcolor{input_id}")
            dpg.delete_item(parent)

        category = trackers.Category(parent=f"categories{self.id}")
        self.category_tracker.add_category(category)
        category.label = category_label
        category.color = category_color
        if data:
            category.complete = data["complete"]
        category.render()

        if not self.changes:
            item = dpg.get_item_configuration(self.parent)
            dpg.configure_item(self.parent, label="!" + item["label"])
            self.changes = True

        # Render the Add Task button
        with simple.group(f"catitems{category.id}",
                          parent=f"catgroup{category.id}"):
            dpg.add_group(f"cattasks{category.id}",
                          parent=f"catitems{category.id}")
            dpg.end()
            dpg.add_indent()
            dpg.add_spacing(name=f"taskspace{category.id}")
            dpg.add_button(
                f"addtask{category.id}",
                label="Add New Task",
                callback=self.add_task,
                callback_data={"category": category.id},
            )
            dpg.unindent()

        return category.id
Example #4
0
 def add_task(self, sender, data):
     random_id = util.generate_random_string()
     parent = dpg.get_item_parent(sender)
     with simple.group(
             f"newtask{random_id}",
             parent=parent.replace("newtask", ""),
             before=f"taskspace{data.get('category')}",
     ):
         dpg.add_indent()
         dpg.add_input_text(f"tasklabel{random_id}", label="")
         dpg.add_same_line(spacing=10)
         dpg.add_button(
             f"taskdone{random_id}",
             label="Done",
             callback=self.submit_task,
             callback_data={
                 "parent": parent,
                 "category": data["category"]
             },
         )
         dpg.unindent()
Example #5
0
 def _setup_add_widget(self, dpg_args) -> None:
     dpgcore.add_indent(name=self.id, **dpg_args)