Ejemplo n.º 1
0
 def compose_workout(self):
     equipment_val = core.get_value("Equipment##widget")
     exercise_type_val = core.get_value("Exercise Type##widget")
     muscle_group_val = core.get_value("Muscle Group##widget")
     if not equipment_val or not exercise_type_val or not muscle_group_val:
         simple.show_item("Fill all the inputs, please.")
     else:
         simple.hide_item("workout_composition_group")
         self._composed_workout = workout_services.get_composed_workout(
             equipment_val, exercise_type_val, muscle_group_val)
         core.add_group(name="buttons", parent="workout_execution_group")
         core.add_table(
             "workout_table",
             ["Exercise", "Sets", "Reps", "Example"],
             parent="workout_execution_group",
             callback=self.toggle,
         )
         for workout in self._composed_workout:
             core.add_row("workout_table", list(workout.values()))
         core.add_button("Cancel##widget",
                         callback=self.cancel_workout,
                         parent="buttons")
         core.add_button("Clear##widget",
                         callback=self.clear_table,
                         parent="buttons")
         core.add_button("Save##widget",
                         callback=self.save_workout,
                         parent="buttons")
Ejemplo n.º 2
0
 def generate_workout_tab(self):
     core.add_spacing(count=10)
     core.add_group(name="workout_execution_group")
     core.add_group(name="workout_composition_group")
     core.add_combo(
         "Equipment##widget",
         items=workout_services.get_criterias_by_name("Equipment"),
         parent="workout_composition_group",
     )
     core.add_spacing(count=4, parent="workout_composition_group")
     core.add_combo(
         "Exercise Type##widget",
         items=workout_services.get_criterias_by_name("Exercise Type"),
         parent="workout_composition_group",
     )
     core.add_spacing(count=4, parent="workout_composition_group")
     core.add_combo(
         "Muscle Group##widget",
         items=workout_services.get_criterias_by_name("Major Muscle"),
         parent="workout_composition_group",
     )
     core.add_spacing(count=4, parent="workout_composition_group")
     core.add_button(
         "Compose Workout##widget",
         parent="workout_composition_group",
         callback=self.compose_workout,
     )
     core.add_text(
         "Fill all the inputs, please.",
         color=[255, 0, 0],
         parent="workout_composition_group",
     )
     simple.hide_item("Fill all the inputs, please.")
Ejemplo n.º 3
0
    def construct(self):
        core.set_main_window_title("Pathfinder")
        core.set_main_window_pos(0, 0)
        core.set_main_window_size(width=self.width, height=self.height)
        core.set_main_window_resizable(resizable=False)

        with simple.window("main_window"):
            core.add_group("main_panel", parent="main_window", horizontal=True)
            # MapDisplay ######################################################
            map_display = MapDisplay("map_display",
                                     parent="main_panel",
                                     tile_radius=1,
                                     latitude=47.4751158,
                                     longitude=19.0057389)
            map_display.construct()

            # InputPanel ######################################################
            core.add_group("user_panel", parent="main_panel", horizontal=False)
            input_panel = InputPanel("input_panel",
                                     parent="user_panel",
                                     map_display=map_display)
            input_panel.construct()

            execution_panel = ExecutionPanel("execution_panel",
                                             parent="user_panel",
                                             plotter=map_display)
            execution_panel.construct()
            core.end()  # user_panel

            ###################################################################
            core.end()  # main_panel
Ejemplo n.º 4
0
    def construct(self):
        with simple.group(self.name, parent=self.parent):
            # GUI elements for the initial coordinate #########################
            core.add_text("Initial coordinate (latitude, longitude)")
            core.add_group("init_input", horizontal=True, horizontal_spacing=0)
            core.add_input_float2("init_coordinate",
                                  label="",
                                  format="%f°",
                                  width=390)
            core.add_button(
                "Sample##input",
                callback=self.sample_by_mouse,
                callback_data=("init_coordinate"),
            )
            core.end()  # init_input

            core.add_spacing(count=5)

            # GUI elements for the destination coordinate #####################
            core.add_text("Destination coordinate (latitude, longitude)")
            core.add_group("destination_input",
                           horizontal=True,
                           horizontal_spacing=0)
            core.add_input_float2("destination_coordinate",
                                  format="%f°",
                                  label="",
                                  width=390)
            core.add_button(
                "Sample##destination",
                callback=self.sample_by_mouse,
                callback_data=("destination_coordinate"),
            )
            core.end()  # destination_input

            core.add_spacing(count=5)
Ejemplo n.º 5
0
 def __init__(self):
     with simple.window("Login Window",
                        no_title_bar=True,
                        autosize=True,
                        no_resize=True):
         core.add_group(name="signup_els")
         core.add_group(name="login_els")
         self.add_login_els()
Ejemplo n.º 6
0
def group(*args,
          show: bool = True,
          parent: str = "",
          before: str = "",
          width: int = 0,
          horizontal: bool = False,
          horizontal_spacing: float = -1.0):
    """Wraps add_group() and automates calling end().

    Args:
        name: Unique name used to programmatically refer to the item. If label is unused this will be the label,
            anything after "##" that occurs in the name will not be shown on screen.
        **show: Decides if the item is shown of not.
        **parent: Parent to add this item to. (runtime adding)
        **before: This item will be displayed before the specified item in the parent. (runtime adding)
        **width: Width of the item.
        **horizontal: Adds the items on the same row by default.
        **horizontal_spacing: Decides the spacing for the items.

    Returns:
        None
    """
    try:
        yield internal_dpg.add_group(*args,
                                     show=show,
                                     parent=parent,
                                     before=before,
                                     width=width,
                                     horizontal=horizontal,
                                     horizontal_spacing=horizontal_spacing)
    finally:
        internal_dpg.end()
Ejemplo n.º 7
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
Ejemplo n.º 8
0
def group(name: str,
          show: bool = True,
          tip: str = "",
          parent: str = "",
          before: str = "",
          width: int = 0,
          horizontal: bool = False,
          horizontal_spacing: float = -1.0):
    try:
        yield internalDPG.add_group(name,
                                    show=show,
                                    tip=tip,
                                    parent=parent,
                                    before=before,
                                    width=width,
                                    horizontal=horizontal,
                                    horizontal_spacing=horizontal_spacing)
    finally:
        internalDPG.end()
Ejemplo n.º 9
0
 def _setup_add_widget(self, dpg_args) -> None:
     dpgcore.add_group(self.id, **dpg_args)
Ejemplo n.º 10
0
    def construct(self):
        with simple.group(self.name, parent=self.parent):
            # GUI elements for the algorithm selection ########################
            core.add_group("algorithm_input##labels",
                           horizontal=True,
                           horizontal_spacing=90)
            core.add_text("Available algorithms")
            core.add_text("Selected algorithms")
            core.end()  # algorithm_input##labels

            core.add_group("algorithm_input#lists",
                           horizontal=True,
                           horizontal_spacing=0)
            core.add_listbox(
                "algorithm_selector##available",
                label="",
                items=self.available_algorithms,
                width=220,
            )
            core.add_listbox(
                "algorithm_selector##selected",
                label="",
                items=self.selected_algorithms,
                width=220,
            )
            core.end()  # algorithm_input##lists

            def move(src, dest, gui_element):
                if len(src):
                    current = core.get_value(gui_element)
                    item = src.pop(current)
                    dest.append(item)
                    self.update_listbox()

            def move_all(src, dest):
                for i in src:
                    dest.append(i)
                src.clear()
                self.update_listbox()

            def add(sender):
                move(
                    self.available_algorithms,
                    self.selected_algorithms,
                    "algorithm_selector##available",
                )

            def add_all(sender):
                move_all(self.available_algorithms, self.selected_algorithms)

            def remove(sender):
                move(
                    self.selected_algorithms,
                    self.available_algorithms,
                    "algorithm_selector##selected",
                )

            def remove_all(sender):
                move_all(self.selected_algorithms, self.available_algorithms)

            core.add_group("algorithm_input##buttons", horizontal=True)
            core.add_button("Add", width=107, callback=add)
            core.add_button("Add all", width=107, callback=add_all)
            core.add_button("Remove", width=107, callback=remove)
            core.add_button("Remove all", width=107, callback=remove_all)
            core.end()  # algorithm_input##buttons
            core.add_button(
                "Execute",
                callback=self.execute_algorithms,
                callback_data=self.selected_algorithms,
            )

            # GUI elements for the metrics display ################################
            core.add_radio_button("metrics",
                                  items=["Elapsed times", "Expanded nodes"],
                                  callback=self.handle_metric,
                                  horizontal=True)
            core.add_plot("Metrics plot")
            core.add_bar_series("Metrics plot", "Metrics", [], [])
            core.set_plot_xlimits("Metrics plot", 0, 6)