import streamlit as st from PIL import Image import stylecloud def create_stylecloud(text, language, icon, colors): output_file = "stylecloud.png" stylecloud.gen_stylecloud(text=text, icon_name=icon, output_name=output_file, colors=colors) return output_file st.title("WordCloud Creator") file = st.file_uploader("Import txt file", type=["txt"]) if file is not None: text = file.getvalue().decode("utf-8") language = st.radio("Language", ["tr", "en"]) icon_options = ["fas fa-car", "fas fa-star", "fas fa-trophy", "fas fa-heart", 'fas fa-wifi', 'fas fa-laptop', 'fas fa-coffee', 'fas fa-radio', 'fas fa-snowflake', 'fas fa-star-and-crescent'] icon = st.selectbox("Icon Selection", icon_options, index=9) color_options = ["black", "white", "red", "blue", "green", "yellow", "orange", "purple" , "pink" , "brown"] colors = st.multiselect("Color Selection", color_options, default=["black"]) if st.button("Create"): output_file = create_stylecloud(text, language, icon, colors) st.markdown(f"### [Download WordCloud](./{output_file})") image = Image.open(output_file) st.image(image, caption='WordCloud', use_column_width=True)