Exemplo n.º 1
0
        "\n" +
        "COMMANDS:\n" +
        "    h          Display this help message\n" +
        "    q          Quit the program\n" +
        "    r          Randomize face\n" +
        "    d D1 D2    Select dimensions D1 and D2\n"
    )
    print help_message
    while not quit:
        command_args = raw_input('Type a command: ').strip().split(" ")
        if command_args[0] == 'h':
            print help_message
        elif command_args[0] == 'q':
            quit = True
        elif command_args[0] == 'r':
            morpher.shuffle()
            im.set_array(morpher.generate_face())
            pyplot.draw()
        elif command_args[0] == 'd':
            if len(command_args) < 3:
                print"  ERROR: need two dimensions to select"
            else:
                try:
                    arg0 = int(command_args[1])
                    arg1 = int(command_args[2])
                    morpher.select_dimensions(arg0, arg1)
                except ValueError:
                    print "  ERROR: Dimensions must be integers in [0, 28]"
                except KeyError:
                    print "  ERROR: Dimensions must be integers in [0, 28]"