Beispiel #1
0
    return path, visited


# Main program.
if __name__ == '__main__':
    # Link functions to buttons.
    callbacks = {
        "update": update_callback,
        "button_1_press": add_obstacle,
        "button_1_drag": add_obstacle,
        "button_1_release": update_callback,
        "button_2_press": remove_obstacle,
        "button_2_drag": remove_obstacle,
        "button_2_release": update_callback,
        "button_3_press": remove_obstacle,
        "button_3_drag": remove_obstacle,
        "button_3_release": update_callback,
    }
    # Extra buttons.
    buttons = [("Clear", clear_obstacles)]

    # Init GUI.
    gui = gui.GUI(
        world_extents, 4, callbacks, buttons, "on",
        "Simple Dijkstra Algorithm (finally shows the optimal path "
        "from start to goal).")

    # Start GUI main loop.
    gui.run()
            if not visited[new_pos] and obstacles[new_pos] != 255:
                heappush(front, (cost + deltacost, new_pos))

    return [], visited


# Main program.
if __name__ == '__main__':
    # Link functions to buttons.
    callbacks = {
        "update": update_callback,
        "button_1_press": add_obstacle,
        "button_1_drag": add_obstacle,
        "button_1_release": update_callback,
        "button_2_press": remove_obstacle,
        "button_2_drag": remove_obstacle,
        "button_2_release": update_callback,
        "button_3_press": remove_obstacle,
        "button_3_drag": remove_obstacle,
        "button_3_release": update_callback,
    }
    # Extra buttons.
    buttons = [("Clear", clear_obstacles)]

    # Init GUI.
    gui = gui.GUI(world_extents, 4, callbacks, buttons, "on",
                  "Simple Dijkstra Algorithm.")

    # Start GUI main loop.
    gui.run()