Python pygame.K_5 Examples

The following are 1 code examples of pygame.K_5(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pygame , or try the search function .
Example #1
Source File: view_convert_dataset.py    From costar_plan with Apache License 2.0 4 votes vote down vote up
def wait_for_keypress_to_select_label(progress_bar):
    """
    # Returns

      description, comment.
    """
    progress_bar.write(
        "\nPress a key to label the file: 1. success, 2. failure, 4. skip, 5. Extra Cool Example, 6. Problem with this Example 0. whoops! make previous file unconfirmed \n"
        "What to look for:\n"
        " - A successful stack is 3 blocks tall or 4 blocks tall with the gripper completely removed from the field of view.\n"
        " - If the tower is 3 blocks tall and blocks will clearly slide off if not for the wall press 2 for 'failure',\n"
        "   if it is merely in contact with a wall, press 1 for 'success'."
        " - When the robot doesn't move but there is already a visible successful stack, that's an error.failure.falsely_appears_correct, so press 1 for 'success'!\n"
        " - If you can see the gripper, the example is a failure even if the stack is tall enough!\n")
    # , 3: error.failure
    flag = 0
    comment = 'none'
    mark_previous_unconfirmed = None
    while flag == 0:
        # pygame.event.pump()
        events = pygame.event.get()
        # if len(events) > 0:
        #     print(events)
        for event in events:
            if event.type == pygame.QUIT:
                pygame.quit()
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_1:
                    progress_bar.write("label set to success")
                    flag = 1
                    return "success", comment, mark_previous_unconfirmed
                elif event.key == pygame.K_2:
                    progress_bar.write("label set to failure")
                    flag = 1
                    return "failure", comment, mark_previous_unconfirmed
                # elif event.key == pygame.K_3:
                #     progress_bar.write("label set to error.failure")
                #     flag = 1
                #     return "error.failure"
                elif event.key == pygame.K_4:
                    flag = 1
                    return 'skip', comment, mark_previous_unconfirmed
                elif event.key == pygame.K_5:
                    comment = 'extra_cool_example'
                    progress_bar.write('comment added: extra_cool_example (this note will remove past notes)')
                elif event.key == pygame.K_6:
                    comment = 'problem_with_example'
                    progress_bar.write('comment added: problem_with_example (this note will remove past notes)')
                elif event.key == pygame.K_0:
                    mark_previous_unconfirmed = True
                    progress_bar.write(
                        'Thanks for mentioning there is a problem with the selection for the previous example.'
                        'We will clear that data so the example will appear again when you re-run the label correction.'
                        'Jut to be extra safe, we also suggest you write down the exact filename '
                        'of the previous example so you can check it manually, ')