Spaces:
Running
Running
File size: 1,234 Bytes
7a531be |
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 |
import streamlit as st
import graphviz
def generate_flowchart(process_text):
dot = graphviz.Digraph()
# Split lines and create nodes
steps = process_text.strip().split("\n")
for i, step in enumerate(steps):
node_label = step.strip()
dot.node(str(i), node_label) # Create a node
if i > 0:
dot.edge(str(i - 1), str(i)) # Connect previous step
return dot
def main():
st.title("Process Flow Diagram Creator")
st.write("Enter your process steps (one step per line) below:")
# Text input area
process_text = st.text_area("Process Steps", height=200)
if st.button("Generate Flowchart"):
if process_text.strip():
flowchart = generate_flowchart(process_text)
st.graphviz_chart(flowchart)
else:
st.warning("Please enter process steps.")
# File uploader for .txt files
uploaded_file = st.file_uploader("Or upload a .txt file", type=["txt"])
if uploaded_file is not None:
process_text = uploaded_file.read().decode("utf-8")
flowchart = generate_flowchart(process_text)
st.graphviz_chart(flowchart)
if __name__ == "__main__":
main()
|