Summary
Hi there!
I use a Steppermotor and would like to show the actual position (every step while moving) in a “metric” container. The code snippet is a simple example how my Steppermotor works. When moving to a position it updates the position value for each step.
Thx in andvance!
Bests Moritz
Steps to reproduce
Code snippet:
import time
class streamlitStepper(object):
position = 0
def __init__(self, position):
self.position = position
def move(self, steps, direction):
for i in range(steps):
self.position = self.position + 1
time.sleep(0.5)
my Streamlit code looks like this
from streamlitStepper import streamlitStepper
import streamlit as st
import threading
st.title("Stepper")
Stepper = streamlitStepper()
if st.button(label='Move'):
moveThread = threading.Thread(target=Stepper.move, args=(10,1,))
moveThread.start()
placeholder = st.empty()
with placeholder.container():
StepperPos = Stepper.position
st.metric(label='Position', value = StepperPos)