Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,65 +1,35 @@
|
|
1 |
import streamlit as st
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
user_text = st.
|
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 |
-
<script>
|
38 |
-
function copyAllResults() {{
|
39 |
-
var results = {st.session_state.results};
|
40 |
-
var allResults = results.join('\\n');
|
41 |
-
var tempTextArea = document.createElement('textarea');
|
42 |
-
tempTextArea.value = allResults;
|
43 |
-
document.body.appendChild(tempTextArea);
|
44 |
-
tempTextArea.select();
|
45 |
-
|
46 |
-
try {{
|
47 |
-
var successful = document.execCommand('copy');
|
48 |
-
if (successful) {{
|
49 |
-
document.getElementById('copyStatus').textContent = 'All results copied to clipboard!';
|
50 |
-
}} else {{
|
51 |
-
throw new Error('Copying failed');
|
52 |
-
}}
|
53 |
-
}} catch (err) {{
|
54 |
-
document.getElementById('copyStatus').textContent = 'Error in copying text: ' + err;
|
55 |
-
}}
|
56 |
-
|
57 |
-
document.body.removeChild(tempTextArea);
|
58 |
-
}}
|
59 |
-
</script>
|
60 |
-
"""
|
61 |
-
html(copy_button_html, height=100)
|
62 |
-
|
63 |
-
st.markdown("---")
|
64 |
-
st.markdown('<span style="color: #FF9933;">जय श्री राम ❤️</span>', unsafe_allow_html=True)
|
65 |
-
st.markdown("Created by Yuyutsu")
|
|
|
1 |
import streamlit as st
|
2 |
+
import pyperclip
|
3 |
+
import time
|
4 |
+
|
5 |
+
def main():
|
6 |
+
st.title("Text Number Prefixer")
|
7 |
+
|
8 |
+
# User input for text
|
9 |
+
user_text = st.text_input("Enter your text:")
|
10 |
+
|
11 |
+
# User input for number
|
12 |
+
number = st.number_input("Select a number between 1 and 100:", min_value=1, max_value=100, value=1)
|
13 |
+
|
14 |
+
# Generate the output
|
15 |
+
output_text = [f"{i+1}{user_text}" for i in range(number)]
|
16 |
+
|
17 |
+
# Display the output with copy buttons
|
18 |
+
for line in output_text:
|
19 |
+
col1, col2 = st.columns([4, 1])
|
20 |
+
with col1:
|
21 |
+
st.write(line)
|
22 |
+
with col2:
|
23 |
+
if st.button(f"Copy {line}"):
|
24 |
+
pyperclip.copy(line)
|
25 |
+
st.success(f"{line} copied to clipboard!")
|
26 |
+
|
27 |
+
# Copy all text to clipboard sequentially
|
28 |
+
if st.button("Copy All"):
|
29 |
+
for line in output_text:
|
30 |
+
pyperclip.copy(line)
|
31 |
+
time.sleep(0.1) # Small delay to ensure each copy operation completes
|
32 |
+
st.success("All text copied to clipboard sequentially!")
|
33 |
+
|
34 |
+
if __name__ == "__main__":
|
35 |
+
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|