awacke1 commited on
Commit
0780026
ยท
verified ยท
1 Parent(s): 8743176

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -0
app.py CHANGED
@@ -1,6 +1,76 @@
1
  import streamlit as st
2
  import os
3
  from PIL import Image
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  # Placeholder function for Wikipedia content fetching
6
  # You'll need to replace this with actual fetching logic
 
1
  import streamlit as st
2
  import os
3
  from PIL import Image
4
+ import json
5
+ from datetime import datetime, timedelta
6
+
7
+ # File to store click history and last update timestamp
8
+ HISTORY_FILE = 'click_history.json'
9
+
10
+ # Initialize or load click history and last update time
11
+ def init_click_history():
12
+ if os.path.exists(HISTORY_FILE):
13
+ with open(HISTORY_FILE, 'r') as file:
14
+ return json.load(file)
15
+ else:
16
+ # Initialize with all buttons set to zero clicks and current time
17
+ return {"click_counts": {button: 0 for button in all_buttons}, "last_update": datetime.now().isoformat()}
18
+
19
+ # Save click history and last update time
20
+ def save_click_history(history):
21
+ with open(HISTORY_FILE, 'w') as file:
22
+ json.dump(history, file)
23
+
24
+ # Update click count for a button and save history
25
+ def update_click_count(button_name):
26
+ history = init_click_history()
27
+ history["click_counts"][button_name] += 1
28
+ history["last_update"] = datetime.now().isoformat()
29
+ save_click_history(history)
30
+ st.experimental_rerun()
31
+
32
+ # Display buttons and handle clicks
33
+ def display_buttons():
34
+ columns = st.columns(3)
35
+ for i, category in enumerate(categories):
36
+ with columns[i % 3]:
37
+ st.markdown(f"### {category['name']}")
38
+ for button in category['buttons']:
39
+ if st.button(button["text"]):
40
+ update_click_count(button["text"])
41
+
42
+ # Calculate time since last update
43
+ def time_since_last_update():
44
+ history = init_click_history()
45
+ last_update = datetime.fromisoformat(history["last_update"])
46
+ now = datetime.now()
47
+ return int((now - last_update).total_seconds())
48
+
49
+ # Main categories and buttons
50
+ categories = [
51
+ {"name": "Inputs", "buttons": [{"text": "๐Ÿ“ Text"}, {"text": "๐Ÿ“– Read"}, {"text": "๐Ÿ“ท Photo"}, {"text": "๐Ÿ–ผ๏ธ View"}, {"text": "๐ŸŽ™๏ธ Record"}, {"text": "๐ŸŽง Listen"}, {"text": "๐ŸŽฅ Video"}, {"text": "๐Ÿ“น Capture"}]},
52
+ {"name": "Outputs", "buttons": [{"text": "๐Ÿ’ฌ Chat"}, {"text": "โœ๏ธ Write"}, {"text": "๐ŸŽจ Art"}, {"text": "๐ŸŒ„ Create"}, {"text": "๐ŸŽต Music"}, {"text": "๐ŸŽถ Compose"}, {"text": "๐Ÿ“ผ Watch"}, {"text": "๐Ÿฟ Movies"}]},
53
+ {"name": "Health", "buttons": [{"text": "๐Ÿ’‰ Vaccinate"}, {"text": "๐Ÿฉบ Diagnose"}, {"text": "๐Ÿฅ Hospital"}, {"text": "๐Ÿš‘ Emergency"}, {"text": "๐Ÿ’Š Meds"}, {"text": "๐Ÿฉน Bandage"}, {"text": "๐Ÿงฌ DNA"}, {"text": "๐Ÿ”ฌ Research"}, {"text": "๐ŸŒก๏ธ Temperature"}, {"text": "๐Ÿ Nutrition"}]},
54
+ {"name": "Learning", "buttons": [{"text": "๐Ÿ“š Study"}, {"text": "๐Ÿง  Brain"}, {"text": "๐Ÿ‘ฉโ€๐ŸŽ“ Graduate"}, {"text": "๐Ÿ“ Measure"}, {"text": "๐Ÿ” Search"}, {"text": "๐Ÿ“Š Analyze"}, {"text": "๐Ÿ“‹ Plan"}, {"text": "๐Ÿ–‹๏ธ Write"}, {"text": "๐Ÿ‘จโ€๐Ÿซ Teach"}, {"text": "๐Ÿงฉ Puzzle"}]},
55
+ {"name": "AI", "buttons": [{"text": "๐Ÿค– Robot"}, {"text": "๐Ÿ‘พ Game"}, {"text": "๐Ÿ’ป Code"}, {"text": "๐Ÿงฎ Calculate"}, {"text": "๐Ÿ“ก Connect"}, {"text": "๐Ÿ”‹ Power"}, {"text": "๐Ÿ•น๏ธ Play"}, {"text": "๐Ÿ–ฅ๏ธ Display"}, {"text": "๐Ÿง‘โ€๐Ÿ’ป Develop"}, {"text": "๐Ÿ‘จโ€๐Ÿ”ฌ Experiment"}]},
56
+ {"name": "Writing", "buttons": [{"text": "โœ๏ธ Author"}, {"text": "๐Ÿ“ Note"}, {"text": "๐Ÿ–Š๏ธ Pen"}, {"text": "๐Ÿ–‹๏ธ Sign"}, {"text": "๐Ÿ“š Library"}, {"text": "๐Ÿ”– Bookmark"}, {"text": "๐Ÿ““ Journal"}, {"text": "โœ’๏ธ Ink"}, {"text": "๐Ÿ“œ Scroll"}]},
57
+ ]
58
+
59
+ all_buttons = [button["text"] for category in categories for button in category["buttons"]]
60
+
61
+ # App title
62
+ st.markdown("# Remixable!!\n## Classifications")
63
+
64
+ # Display all buttons
65
+ display_buttons()
66
+
67
+ # Show time since last update
68
+ seconds_since_update = time_since_last_update()
69
+ st.write(f"๐Ÿ•’ Time since last update: {seconds_since_update} seconds")
70
+
71
+
72
+
73
+
74
 
75
  # Placeholder function for Wikipedia content fetching
76
  # You'll need to replace this with actual fetching logic