Lashtw commited on
Commit
8e97d0d
·
verified ·
1 Parent(s): 95c0eca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -17
app.py CHANGED
@@ -4,28 +4,41 @@ import requests
4
  import json
5
  from io import StringIO
6
 
7
- # 圓周率與無限猴子定理的介紹
8
  st.title("探索圓周率與無限猴子定理的奇妙世界")
9
  st.write("""
10
  歡迎參加這個有趣的活動!我們將一起探索圓周率 (π) 和無限猴子定理的奧秘,並透過幸運數字查詢系統,發現你選的數字在 π 中的秘密。
11
  """)
12
 
13
- # 插入五張 GIF 圖片,每張獨占一列
14
- col1 = st.columns(1) # 單列佈局
15
- with col1[0]:
16
- st.image("m1.GIF", caption="圓周率無限猴子定理的奇妙關聯", use_column_width=True)
17
- col2 = st.columns(1)
18
- with col2[0]:
19
- st.image("m2.GIF", caption="重複與不重複", use_column_width=True)
20
- col3 = st.columns(1)
21
- with col3[0]:
22
- st.image("m3.GIF", caption="圓周率裡藏著你的幸運號碼", use_column_width=True)
23
- col4 = st.columns(1)
24
- with col4[0]:
25
- st.image("m4.GIF", caption="無限猴子定理是什麼?", use_column_width=True)
26
- col5 = st.columns(1)
27
- with col5[0]:
28
- st.image("m5.GIF", caption="圓周率是無限長的數字打字機", use_column_width=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  # 分隔線
31
  st.markdown("---")
 
4
  import json
5
  from io import StringIO
6
 
7
+ # 圓周率與無限猴子定理的介紹與分頁圖片展示
8
  st.title("探索圓周率與無限猴子定理的奇妙世界")
9
  st.write("""
10
  歡迎參加這個有趣的活動!我們將一起探索圓周率 (π) 和無限猴子定理的奧秘,並透過幸運數字查詢系統,發現你選的數字在 π 中的秘密。
11
  """)
12
 
13
+ # 定義圖片和標題
14
+ image_data = [
15
+ {"path": "m1.GIF", "caption": "圓周率與無限猴子定理的奇妙關聯"},
16
+ {"path": "m2.GIF", "caption": "重複不重複"},
17
+ {"path": "m3.GIF", "caption": "圓周率裡藏著你的幸運號碼"},
18
+ {"path": "m4.GIF", "caption": "無限猴子定理是什麼?"},
19
+ {"path": "m5.GIF", "caption": "圓周率是無限長的數字打字機"},
20
+ ]
21
+
22
+ # 初始化 session state 用於追蹤當前頁面
23
+ if 'page' not in st.session_state:
24
+ st.session_state.page = 0
25
+
26
+ # 顯示當前頁面的圖片
27
+ st.image(image_data[st.session_state.page]["path"],
28
+ caption=image_data[st.session_state.page]["caption"],
29
+ use_container_width=True)
30
+
31
+ # 換頁按鈕
32
+ col1, col2 = st.columns(2)
33
+ with col1:
34
+ if st.button("上一頁") and st.session_state.page > 0:
35
+ st.session_state.page -= 1
36
+ with col2:
37
+ if st.button("下一頁") and st.session_state.page < len(image_data) - 1:
38
+ st.session_state.page += 1
39
+
40
+ # 顯示當前頁數
41
+ st.write(f"頁面: {st.session_state.page + 1} / {len(image_data)}")
42
 
43
  # 分隔線
44
  st.markdown("---")