eaglelandsonce commited on
Commit
74ac74b
·
verified ·
1 Parent(s): 404efa3

Update pages/03_Talk_to_the_Greats.py

Browse files
Files changed (1) hide show
  1. pages/03_Talk_to_the_Greats.py +31 -36
pages/03_Talk_to_the_Greats.py CHANGED
@@ -1,55 +1,50 @@
1
  import streamlit as st
2
  from PIL import Image
3
- import base64
4
-
5
- # Helper function to encode image to base64
6
- def image_to_base64(image_path):
7
- with open(image_path, "rb") as img_file:
8
- return base64.b64encode(img_file.read()).decode()
9
 
10
  # Page Title
11
  st.title("Talk with the Great Physicist")
12
 
13
- # Image paths
14
- images = [
15
- ("Einstein", "images/image01.png", "https://chatgpt.com/g/g-ocQnGKXGx-einstein-learn-relativity"),
16
- ("Dirac", "images/image02.png", "https://chatgpt.com/g/g-JjKhIfBft-dirac-learn-quantum-mechanics"),
17
- ("Feynman", "images/image03.png", "https://chatgpt.com/g/g-stfxVmJcu-feynman-learn-physics"),
18
- ("Maxwell", "images/image04.png", "https://chatgpt.com/g/g-cxxsVKyoj-maxwell-learn-electromagnetism"),
19
- ("Newton", "images/image05.png", "https://chatgpt.com/g/g-yIo2Tvujk-newton-learn-classical-mechanics"),
20
- ("Chat with All", "images/image06.png", "https://chatgpt.com/g/g-5jFCsQ6x4-dialog-with-the-great-physicists")
 
 
 
 
 
 
 
 
21
  ]
22
 
23
- # Function to create clickable images with hover effect
24
- def clickable_image(image_name, image_path, link):
25
- # Convert image to base64 for embedding
26
- img_base64 = image_to_base64(image_path)
27
-
28
- # HTML with hover effect and link
29
- html_code = f"""
30
- <a href="{link}" target="_blank">
31
- <img src="data:image/png;base64,{img_base64}" alt="{image_name}"
32
- style="border: 2px solid transparent; border-radius: 10px; width: 100%;"
33
- onmouseover="this.style.borderColor='#007BFF';"
34
- onmouseout="this.style.borderColor='transparent';">
35
- </a>
36
- """
37
- st.markdown(html_code, unsafe_allow_html=True)
38
-
39
  # Create three columns for the images
40
  col1, col2, col3 = st.columns(3)
41
 
42
  # First column (Einstein and Maxwell)
43
  with col1:
44
- clickable_image(*images[0]) # Einstein
45
- clickable_image(*images[3]) # Maxwell
 
 
 
46
 
47
  # Second column (Dirac and Newton)
48
  with col2:
49
- clickable_image(*images[1]) # Dirac
50
- clickable_image(*images[4]) # Newton
 
 
 
51
 
52
  # Third column (Feynman and Chat with All)
53
  with col3:
54
- clickable_image(*images[2]) # Feynman
55
- clickable_image(*images[5]) # Chat with All
 
 
 
 
1
  import streamlit as st
2
  from PIL import Image
 
 
 
 
 
 
3
 
4
  # Page Title
5
  st.title("Talk with the Great Physicist")
6
 
7
+ # Load Images
8
+ image1 = Image.open("images/image01.png") # Einstein
9
+ image2 = Image.open("images/image02.png") # Dirac
10
+ image3 = Image.open("images/image03.png") # Feynman
11
+ image4 = Image.open("images/image04.png") # Maxwell
12
+ image5 = Image.open("images/image05.png") # Newton
13
+ image6 = Image.open("images/image06.png") # Chat with All
14
+
15
+ # Define image links and names
16
+ image_links = [
17
+ ("Einstein", "https://chatgpt.com/g/g-ocQnGKXGx-einstein-learn-relativity", image1),
18
+ ("Dirac", "https://chatgpt.com/g/g-JjKhIfBft-dirac-learn-quantum-mechanics", image2),
19
+ ("Feynman", "https://chatgpt.com/g/g-stfxVmJcu-feynman-learn-physics", image3),
20
+ ("Maxwell", "https://chatgpt.com/g/g-cxxsVKyoj-maxwell-learn-electromagnetism", image4),
21
+ ("Newton", "https://chatgpt.com/g/g-yIo2Tvujk-newton-learn-classical-mechanics", image5),
22
+ ("Chat with All", "https://chatgpt.com/g/g-5jFCsQ6x4-dialog-with-the-great-physicists", image6),
23
  ]
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  # Create three columns for the images
26
  col1, col2, col3 = st.columns(3)
27
 
28
  # First column (Einstein and Maxwell)
29
  with col1:
30
+ st.image(image1)
31
+ st.markdown(f"[Einstein](https://chatgpt.com/g/g-ocQnGKXGx-einstein-learn-relativity)")
32
+
33
+ st.image(image4)
34
+ st.markdown(f"[Maxwell](https://chatgpt.com/g/g-cxxsVKyoj-maxwell-learn-electromagnetism)")
35
 
36
  # Second column (Dirac and Newton)
37
  with col2:
38
+ st.image(image2)
39
+ st.markdown(f"[Dirac](https://chatgpt.com/g/g-JjKhIfBft-dirac-learn-quantum-mechanics)")
40
+
41
+ st.image(image5)
42
+ st.markdown(f"[Newton](https://chatgpt.com/g/g-yIo2Tvujk-newton-learn-classical-mechanics)")
43
 
44
  # Third column (Feynman and Chat with All)
45
  with col3:
46
+ st.image(image3)
47
+ st.markdown(f"[Feynman](https://chatgpt.com/g/g-stfxVmJcu-feynman-learn-physics)")
48
+
49
+ st.image(image6)
50
+ st.markdown(f"[Chat with All](https://chatgpt.com/g/g-5jFCsQ6x4-dialog-with-the-great-physicists)")