awacke1 commited on
Commit
d8ff977
โ€ข
1 Parent(s): 8717f4a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -105
app.py CHANGED
@@ -1,115 +1,68 @@
1
  import streamlit as st
2
  import os
3
- from PIL import Image
4
 
5
- st.markdown('''
6
- # Remixable!
7
- ''')
8
 
9
- col1, col2, col3 = st.columns(3)
 
 
10
 
11
- with col1:
12
- st.markdown('''### Inputs''')
13
- st.button("๐Ÿ“ Text")
14
- st.button("๐Ÿ“– Read")
15
- st.button("๐Ÿ“ท Photo")
16
- st.button("๐Ÿ–ผ๏ธ View")
17
- st.button("๐ŸŽ™๏ธ Record")
18
- st.button("๐ŸŽง Listen")
19
- st.button("๐ŸŽฅ Video")
20
- st.button("๐Ÿ“น Capture")
 
 
 
 
 
 
21
 
22
- with col2:
23
- st.markdown('''### Outputs''')
24
- st.button("๐Ÿ’ฌ Chat")
25
- st.button("โœ๏ธ Write")
26
- st.button("๐ŸŽจ Art")
27
- st.button("๐ŸŒ„ Create")
28
- st.button("๐ŸŽต Music")
29
- st.button("๐ŸŽถ Compose")
30
- st.button("๐Ÿ“ผ Watch")
31
- st.button("๐Ÿฟ Movies")
32
 
33
- with col3:
34
- st.markdown('''### Health''')
35
- st.button("๐Ÿ’‰ Vaccinate")
36
- st.button("๐Ÿฉบ Diagnose")
37
- st.button("๐Ÿฅ Hospital")
38
- st.button("๐Ÿš‘ Emergency")
39
- st.button("๐Ÿ’Š Meds")
40
- st.button("๐Ÿฉน Bandage")
41
- st.button("๐Ÿงฌ DNA")
42
- st.button("๐Ÿ”ฌ Research")
43
- st.button("๐ŸŒก๏ธ Temperature")
44
- st.button("๐Ÿ Nutrition")
45
 
46
- col4, col5, col6 = st.columns(3)
 
 
 
 
 
 
 
 
 
 
47
 
48
- with col4:
49
- st.markdown('''### Learning''')
50
- st.button("๐Ÿ“š Study")
51
- st.button("๐Ÿง  Brain")
52
- st.button("๐Ÿ‘ฉโ€๐ŸŽ“ Graduate")
53
- st.button("๐Ÿ“ Measure")
54
- st.button("๐Ÿ” Search")
55
- st.button("๐Ÿ“Š Analyze")
56
- st.button("๐Ÿ“‹ Plan")
57
- st.button("๐Ÿ–‹๏ธ Write")
58
- st.button("๐Ÿ‘จโ€๐Ÿซ Teach")
59
- st.button("๐Ÿงฉ Puzzle")
60
 
61
- with col5:
62
- st.markdown('''### AI''')
63
- st.button("๐Ÿค– Robot")
64
- st.button("๐Ÿ‘พ Game")
65
- st.button("๐Ÿ’ป Code")
66
- st.button("๐Ÿงฎ Calculate")
67
- st.button("๐Ÿ“ก Connect")
68
- st.button("๐Ÿ”‹ Power")
69
- st.button("๐Ÿ•น๏ธ Play")
70
- st.button("๐Ÿ–ฅ๏ธ Display")
71
- st.button("๐Ÿง‘โ€๐Ÿ’ป Develop")
72
- st.button("๐Ÿ‘จโ€๐Ÿ”ฌ Experiment")
73
-
74
- with col6:
75
- st.markdown('''### Writing''')
76
- st.button("โœ๏ธ Author")
77
- st.button("๐Ÿ“ Note")
78
- st.button("๐Ÿ–Š๏ธ Pen")
79
- st.button("๐Ÿ–‹๏ธ Sign")
80
- st.button("๐Ÿ“š Library")
81
- st.button("๐Ÿ”– Bookmark")
82
- st.button("๐Ÿ““ Journal")
83
- st.button("โœ’๏ธ Ink")
84
- st.button("๐Ÿ“œ Scroll")
85
-
86
- def display_images_and_wikipedia_summaries():
87
- st.title('Gallery with Related Stories')
88
- image_files = [f for f in os.listdir('.') if f.endswith('.png')]
89
- if not image_files:
90
- st.write("No PNG images found in the current directory.")
91
- return
92
- for image_file in image_files:
93
- image = Image.open(image_file)
94
- st.image(image, caption=image_file, use_column_width='always')
95
- keyword = image_file.split('.')[0] # Assumes keyword is the file name without extension
96
-
97
- display_images_and_wikipedia_summaries()
98
-
99
- st.markdown('# Three Dragons ๐Ÿ‰๐ŸŒ Mythical Dragons Around the World by Aaron Wacker')
100
- dragons = {
101
- '#Fafnir #Norse': '- **Story**: Fafnir originally a dwarf, transformed into a fierce dragon due to his greed for the treasure he guarded. He was later slain by the hero Sigurd. - **Significance**: deadly sin of greed and the corrupting power of wealth.',
102
- '#Quetzalcoatl #Aztec': '- **Story**: Quetzalcoatl, the Feathered Serpent, is not a dragon in the traditional sense but shares many similarities. He was a deity representing wind, air, and learning. - **Significance**: creator god and a symbol of death and rebirth.',
103
- '#Tiamat #Mesopotamian': '- **Story**: Tiamat, primordial goddess of ocean, turned into a dragon-like creature in a battle against her children who threatened her authority. - **Significance**: chaos of primordial creation and is often associated with the forces of nature.'
104
- }
105
- for dragon, story in dragons.items():
106
- st.subheader(dragon)
107
- st.markdown(f"- {story}")
108
- st.markdown('''
109
- https://github.com/AaronCWacker/ThreeDragons
110
- ![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/vkNh6XnEtGSj8mXea1W6p.png)
111
- ![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/Kr_nqtaglHE_aiFxWH9zF.png)
112
- ![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/WLRKWqB6dKlMH6saVV9cX.png)
113
- ![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/Lyazf6FuX4nH__4illVki.png)
114
- ![image/png](https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/ZemsxlT3b5idB0W5IjL1o.png)
115
- ''')
 
1
  import streamlit as st
2
  import os
3
+ import json
4
 
5
+ # Directory to store scores
6
+ score_dir = "scores"
7
+ os.makedirs(score_dir, exist_ok=True)
8
 
9
+ # Function to generate a unique key for each button
10
+ def generate_key(label, header, idx):
11
+ return f"{header}_{label}_{idx}"
12
 
13
+ # Function to increment score and save it
14
+ def update_score(key, increment=1):
15
+ score_file = os.path.join(score_dir, f"{key}.json")
16
+ if os.path.exists(score_file):
17
+ with open(score_file, "r") as file:
18
+ score_data = json.load(file)
19
+ else:
20
+ score_data = {"clicks": 0, "score": 0}
21
+
22
+ score_data["clicks"] += 1
23
+ score_data["score"] += increment
24
+
25
+ with open(score_file, "w") as file:
26
+ json.dump(score_data, file)
27
+
28
+ return score_data["score"]
29
 
30
+ # Function to load score
31
+ def load_score(key):
32
+ score_file = os.path.join(score_dir, f"{key}.json")
33
+ if os.path.exists(score_file):
34
+ with open(score_file, "r") as file:
35
+ score_data = json.load(file)
36
+ return score_data["score"]
37
+ return 0
 
 
38
 
39
+ # Display headers and buttons with scores
40
+ def display_buttons_with_scores():
41
+ headers = ["Inputs", "Outputs", "Health", "Learning", "AI", "Writing"]
42
+ buttons = [
43
+ ["๐Ÿ“ Text", "๐Ÿ“– Read", "๐Ÿ“ท Photo", "๐Ÿ–ผ๏ธ View", "๐ŸŽ™๏ธ Record", "๐ŸŽง Listen", "๐ŸŽฅ Video", "๐Ÿ“น Capture"],
44
+ ["๐Ÿ’ฌ Chat", "โœ๏ธ Write", "๐ŸŽจ Art", "๐ŸŒ„ Create", "๐ŸŽต Music", "๐ŸŽถ Compose", "๐Ÿ“ผ Watch", "๐Ÿฟ Movies"],
45
+ ["๐Ÿ’‰ Vaccinate", "๐Ÿฉบ Diagnose", "๐Ÿฅ Hospital", "๐Ÿš‘ Emergency", "๐Ÿ’Š Meds", "๐Ÿฉน Bandage", "๐Ÿงฌ DNA", "๐Ÿ”ฌ Research", "๐ŸŒก๏ธ Temperature", "๐Ÿ Nutrition"],
46
+ ["๐Ÿ“š Study", "๐Ÿง  Brain", "๐Ÿ‘ฉโ€๐ŸŽ“ Graduate", "๐Ÿ“ Measure", "๐Ÿ” Search", "๐Ÿ“Š Analyze", "๐Ÿ“‹ Plan", "๐Ÿ–‹๏ธ Write", "๐Ÿ‘จโ€๐Ÿซ Teach", "๐Ÿงฉ Puzzle"],
47
+ ["๐Ÿค– Robot", "๐Ÿ‘พ Game", "๐Ÿ’ป Code", "๐Ÿงฎ Calculate", "๐Ÿ“ก Connect", "๐Ÿ”‹ Power", "๐Ÿ•น๏ธ Play", "๐Ÿ–ฅ๏ธ Display", "๐Ÿง‘โ€๐Ÿ’ป Develop", "๐Ÿ‘จโ€๐Ÿ”ฌ Experiment"],
48
+ ["โœ๏ธ Author", "๐Ÿ“ Note", "๐Ÿ–Š๏ธ Pen", "๐Ÿ–‹๏ธ Sign", "๐Ÿ“š Library", "๐Ÿ”– Bookmark", "๐Ÿ““ Journal", "โœ’๏ธ Ink", "๐Ÿ“œ Scroll"]
49
+ ]
 
50
 
51
+ cols = st.columns(len(headers))
52
+ for idx, (col, header, buttons_list) in enumerate(zip(cols, headers, buttons)):
53
+ with col:
54
+ st.markdown(f"### {header}")
55
+ for button_idx, button_label in enumerate(buttons_list, start=1):
56
+ key = generate_key(button_label, header, button_idx)
57
+ score = load_score(key)
58
+ if st.button(f"{button_label} {score}", key=key):
59
+ new_score = update_score(key)
60
+ # Reload the page to reflect the updated score
61
+ st.experimental_rerun()
62
 
63
+ # Main application logic
64
+ if __name__ == "__main__":
65
+ st.markdown('# Remixable!')
66
+ display_buttons_with_scores()
 
 
 
 
 
 
 
 
67
 
68
+ # Additional content and functionality can go here