Spaces:
Runtime error
Runtime error
File size: 1,567 Bytes
e590319 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# 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.
import streamlit as st
import lottie
import altair as alt
import numpy as np
# Create a streamlit sidebar to move the lottie animation
st.sidebar.title('Move the Lottie Animation')
# Get the lottie file url value
lottie_file = st.sidebar.text_input('Lottie File URL',
'https://assets6.lottiefiles.com/packages/lf20_Bx6U8v.json')
# Create a function to move the lottie animation up
@st.cache(allow_output_mutation=True)
def move_up():
lottie_file.y += 10
# Create a function to move the lottie animation down
@st.cache(allow_output_mutation=True)
def move_down():
lottie_file.y -= 10
# Create a function to move the lottie animation left
@st.cache(allow_output_mutation=True)
def move_left():
lottie_file.x -= 10
# Create a function to move the lottie animation right
@st.cache(allow_output_mutation=True)
def move_right():
lottie_file.x += 10
# Create four buttons for the streamlit sidebar
if st.sidebar.button('Up'):
move_up()
if st.sidebar.button('Down'):
move_down()
if st.sidebar.button('Left'):
move_left()
if st.sidebar.button('Right'):
move_right()
# Plot the lottie animation
st.altair_chart(alt.Chart(np.array([lottie_file])).mark_circle().encode(
x='x', y='y'
)) |