Пример #1
0
def test():
    button.destroy()
    welcome_message.destroy()
    free.destroy()
    free2.destroy()
    instruction = Text(app, text="Push the red circle as soon as he appears")
    instruction.text_color = "white"
    board = Waffle(app, height=5, width=5, visible=True)
    board.pixel_size = 75
    board.set_all("white")
    app.update()
    waitingTime = (random.randint(0, 10))
    time.sleep(waitingTime)
    starttime = time.perf_counter()

    def ende(x, y):
        if board[x, y].dotty == True:
            board[x, y].dotty = False
            board.set_pixel(x, y, "white")
            end = time.perf_counter()
            timeused = round((end - starttime) * 1000) / 1000
            timedisplay = Text(app,
                               text="Your reaction-time: " + str(timeused) +
                               "s")
            timedisplay.text_color = "white"
            timedisplay.font = "Impact"

    board.update_command(ende)
    x, y = random.randint(0, 4), random.randint(0, 4)
    board[x, y].dotty = True
    board.set_pixel(x, y, "red")
Пример #2
0
def test_getters_setters():
    a = App()
    w = Waffle(a)

    w.width = 10
    assert w.width == 10
    w.height = 11
    assert w.height == 11
    w.pixel_size = 12
    assert w.pixel_size == 12
    w.pad = 13
    assert w.pad == 13
    w.color = "red"
    assert w.color == "red"
    w.dotty = True
    assert w.dotty == True

    a.destroy()