awacke1 commited on
Commit
e590319
·
1 Parent(s): 111ae53

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -0
app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ChatGPT Prompt: write a python streamlit program that shows lottie animation files moving around the screen. Create a streamlit sidebar which gives you four buttons that allow you to move the lottie animation up down left and right on the screen. use lottie file url value of actual animated lottie files for the input.
2
+
3
+ import streamlit as st
4
+ import lottie
5
+ import altair as alt
6
+ import numpy as np
7
+
8
+ # Create a streamlit sidebar to move the lottie animation
9
+ st.sidebar.title('Move the Lottie Animation')
10
+
11
+ # Get the lottie file url value
12
+ lottie_file = st.sidebar.text_input('Lottie File URL',
13
+ 'https://assets6.lottiefiles.com/packages/lf20_Bx6U8v.json')
14
+
15
+ # Create a function to move the lottie animation up
16
+ @st.cache(allow_output_mutation=True)
17
+ def move_up():
18
+ lottie_file.y += 10
19
+
20
+ # Create a function to move the lottie animation down
21
+ @st.cache(allow_output_mutation=True)
22
+ def move_down():
23
+ lottie_file.y -= 10
24
+
25
+ # Create a function to move the lottie animation left
26
+ @st.cache(allow_output_mutation=True)
27
+ def move_left():
28
+ lottie_file.x -= 10
29
+
30
+ # Create a function to move the lottie animation right
31
+ @st.cache(allow_output_mutation=True)
32
+ def move_right():
33
+ lottie_file.x += 10
34
+
35
+ # Create four buttons for the streamlit sidebar
36
+ if st.sidebar.button('Up'):
37
+ move_up()
38
+
39
+ if st.sidebar.button('Down'):
40
+ move_down()
41
+
42
+ if st.sidebar.button('Left'):
43
+ move_left()
44
+
45
+ if st.sidebar.button('Right'):
46
+ move_right()
47
+
48
+ # Plot the lottie animation
49
+ st.altair_chart(alt.Chart(np.array([lottie_file])).mark_circle().encode(
50
+ x='x', y='y'
51
+ ))