-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdesign.py
29 lines (20 loc) · 1.2 KB
/
design.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import streamlit as st
import time
from typeing import Wpm
def gui():
st.title("Typing Test Game")
st.write("Welcome to the Typing Test Game! Type the following text as fast as you can within 30 seconds:")
text_to_type = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
st.write(text_to_type)
user_input = st.text_area("Type here:", height=200)
start_time = time.time()
timer_placeholder = st.empty() # Placeholder for timer
timer = 30
while timer > 0:
timer = 30 - int(time.time() - start_time)
timer_placeholder.write("Time remaining: {} seconds".format(timer))
time.sleep(1)
time_taken = time.time() - start_time
wpm = Wpm.calculate_wpm(user_input, time_taken)
st.write("Time's up!")
st.write("Your typing speed is: {} WPM".format(wpm))