awacke1 commited on
Commit
93c4074
·
1 Parent(s): 87536cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -14
app.py CHANGED
@@ -14,39 +14,38 @@ emojis = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7
14
  def spinning_model(theme, nodes, emojis):
15
  output = ""
16
  for i, node in enumerate(nodes):
17
- output += f"{emojis[i]} {node}\n"
18
- time.sleep(0.1)
19
- st.markdown(f"### {theme}\n{output}")
20
- st.write("---")
21
 
22
- def random_timer():
23
- countdown = 5
24
  while countdown > 0:
25
- st.write(f"Countdown: {countdown} seconds")
26
  time.sleep(1)
27
  countdown -= 1
28
- st.experimental_rerun()
29
 
30
  st.title("Spinning Model Visualization")
31
- st.write("Select themes to display the spinning model.")
32
 
33
- # Add input widgets for the two themes
34
  theme_1 = st.text_input("Theme 1:", "Theme 1")
35
  theme_2 = st.text_input("Theme 2:", "Theme 2")
 
36
 
37
  # Get the selected themes and their nodes
38
  selected_theme_1 = themes.get(theme_1, [])
39
  selected_theme_2 = themes.get(theme_2, [])
40
 
41
  while True:
42
- # Randomly select a theme to display
43
  if random.randint(0, 1):
44
  selected_theme = selected_theme_1
45
  theme = theme_1
46
  else:
47
  selected_theme = selected_theme_2
48
  theme = theme_2
49
-
 
50
  spinning_model(theme, selected_theme, emojis)
51
- random_timer()
52
- st.write("---")
 
14
  def spinning_model(theme, nodes, emojis):
15
  output = ""
16
  for i, node in enumerate(nodes):
17
+ output += f"{emojis[i]} {node} "
18
+ st.markdown(f"### {theme}\n{output}")
19
+ st.write("---")
 
20
 
21
+ def random_timer(countdown):
 
22
  while countdown > 0:
23
+ st.write(f"Next refresh in {countdown} seconds.")
24
  time.sleep(1)
25
  countdown -= 1
26
+ return random.sample(range(1, 11), 10)
27
 
28
  st.title("Spinning Model Visualization")
29
+ st.write("Select themes to display the spinning model and adjust the number of seconds before the next refresh.")
30
 
31
+ # Add input widgets for the two themes and refresh interval
32
  theme_1 = st.text_input("Theme 1:", "Theme 1")
33
  theme_2 = st.text_input("Theme 2:", "Theme 2")
34
+ refresh_interval = st.slider("Refresh interval (in seconds):", 1, 10, 5)
35
 
36
  # Get the selected themes and their nodes
37
  selected_theme_1 = themes.get(theme_1, [])
38
  selected_theme_2 = themes.get(theme_2, [])
39
 
40
  while True:
41
+ # Randomly select a theme to display and shuffle the nodes
42
  if random.randint(0, 1):
43
  selected_theme = selected_theme_1
44
  theme = theme_1
45
  else:
46
  selected_theme = selected_theme_2
47
  theme = theme_2
48
+ random.shuffle(selected_theme)
49
+
50
  spinning_model(theme, selected_theme, emojis)
51
+ selected_theme = random_timer(refresh_interval)