File size: 1,047 Bytes
13a60c2
8912a3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pyperclip
import time

def main():
    st.title("Text Number Prefixer")

    # User input for text
    user_text = st.text_input("Enter your text:")

    # User input for number
    number = st.number_input("Select a number between 1 and 100:", min_value=1, max_value=100, value=1)

    # Generate the output
    output_text = [f"{i+1}{user_text}" for i in range(number)]

    # Display the output with copy buttons
    for line in output_text:
        col1, col2 = st.columns([4, 1])
        with col1:
            st.write(line)
        with col2:
            if st.button(f"Copy {line}"):
                pyperclip.copy(line)
                st.success(f"{line} copied to clipboard!")

    # Copy all text to clipboard sequentially
    if st.button("Copy All"):
        for line in output_text:
            pyperclip.copy(line)
            time.sleep(0.1)  # Small delay to ensure each copy operation completes
        st.success("All text copied to clipboard sequentially!")

if __name__ == "__main__":
    main()