Пример #1
0
 def test_update_sequence_rollover(self):
     timer = Ptimer()
     timer.toggle_pause()
     assert timer.started is True
     timer.time_elapsed = 8000
     timer.round = 7
     assert timer.round == 7
     timer.update()
     assert timer.round == 0
Пример #2
0
    def test_reset(self):
        timer = Ptimer()
        timer.toggle_pause()
        time.sleep(1)
        timer.update()
        assert timer.time_elapsed != 0
        assert timer.last_time != 0

        timer.reset()
        assert timer.time_elapsed == 0
        assert timer.last_time == 0
        assert timer.started is False
Пример #3
0
 def test_init_values(self):
     timer = Ptimer()
     assert timer.sequence_times == {
         'round': 1500,
         'break': 300,
         'long break': 1200
     }
     assert timer.started is False
     assert timer.round == 0
     assert timer.last_time == 0
     assert timer.time_elapsed == 0
Пример #4
0
    def test_full_round(self):
        timer = Ptimer()
        timer.toggle_pause()

        for i in range(8):
            assert timer.round == i
            timer.time_elapsed = 8000
            timer.update()
        assert timer.time_label.text == "Sequence over! Good job!"
        assert timer.round == 0
Пример #5
0
 def test_pause(self):
     timer = Ptimer()
     assert timer.started is False
     timer.toggle_pause()
     assert timer.started is True
     assert timer.last_time != 0
     timer.toggle_pause()
     assert timer.started is False
Пример #6
0
 def test_format_time(self):
     timer = Ptimer()
     timer.time_elapsed = 1500
     assert timer.format_time() == '00:00'
Пример #7
0
time_settings = [25, 5, 20]
if len(sys.argv) == 4:
    time_settings = sys.argv[1:]
else:
    if len(sys.argv) != 1:
        print(":::::::::::::::::::::::::::::")
        print(
            "Usage: python gui_main.py [round length in minutes] [break length in minutes] [long break length in minutes]"
        )
        print("Example: python gui_main 20.1 5.2 12")
        print("Inputting no arguments will use default values of 25 5 20")
        print(":::::::::::::::::::::::::::::")
        sys.exit(1)

timer = Ptimer(time_settings)
window = Window(700, 500)

# grey background
pyglet.gl.glClearColor(.8, .8, .8, 1)


def update(self):
    timer.update()


@window.event
def on_mouse_release(x, y, button, modifiers):
    timer.on_mouse_release(x, y, button, modifiers)