Junaidb commited on
Commit
21e4748
·
verified ·
1 Parent(s): ae9e79c

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +88 -38
src/streamlit_app.py CHANGED
@@ -1,40 +1,90 @@
1
- import altair as alt
2
- import numpy as np
3
- import pandas as pd
4
  import streamlit as st
5
 
6
- """
7
- # Welcome to Streamlit!
8
-
9
- Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
10
- If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
11
- forums](https://discuss.streamlit.io).
12
-
13
- In the meantime, below is an example of what you can do with just a few lines of code:
14
- """
15
-
16
- num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
17
- num_turns = st.slider("Number of turns in spiral", 1, 300, 31)
18
-
19
- indices = np.linspace(0, 1, num_points)
20
- theta = 2 * np.pi * num_turns * indices
21
- radius = indices
22
-
23
- x = radius * np.cos(theta)
24
- y = radius * np.sin(theta)
25
-
26
- df = pd.DataFrame({
27
- "x": x,
28
- "y": y,
29
- "idx": indices,
30
- "rand": np.random.randn(num_points),
31
- })
32
-
33
- st.altair_chart(alt.Chart(df, height=700, width=700)
34
- .mark_point(filled=True)
35
- .encode(
36
- x=alt.X("x", axis=None),
37
- y=alt.Y("y", axis=None),
38
- color=alt.Color("idx", legend=None, scale=alt.Scale()),
39
- size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
40
- ))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
 
3
+ st.set_page_config(
4
+ layout="wide"
5
+ )
6
+ # Minimal Heading
7
+ st.title("My Streamlit Application")
8
+
9
+ # Custom CSS for styling the cards, ensuring equal height and spacing
10
+ st.markdown(
11
+ """
12
+ <style>
13
+ /* Style for the card container */
14
+ .st-emotion-cache-1r6dm1c { /* This targets the columns container */
15
+ gap: 2rem; /* Adjust this value for the distance between cards */
16
+ }
17
+
18
+ /* General card styling */
19
+ .card {
20
+ border: 1px solid #e6e6e6; /* Light border */
21
+ border-radius: 10px; /* Rounded corners */
22
+ padding: 25px; /* Padding inside the card */
23
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); /* Subtle shadow */
24
+ display: flex;
25
+ flex-direction: column;
26
+ justify-content: space-between; /* Distribute content vertically */
27
+ height: 350px; /* Fixed height for equal cards */
28
+ background-color: #ffffff; /* White background */
29
+ }
30
+
31
+ /* Ensure text input and button fit well */
32
+ .stTextInput > div > div > input {
33
+ border-radius: 5px;
34
+ padding: 10px;
35
+ }
36
+
37
+ .stButton > button {
38
+ width: 100%; /* Make button full width */
39
+ border-radius: 5px;
40
+ padding: 10px 0;
41
+ margin-top: 15px; /* Space above the button */
42
+ background-color: #4CAF50; /* Green button */
43
+ color: white;
44
+ font-weight: bold;
45
+ border: none;
46
+ cursor: pointer;
47
+ transition: background-color 0.3s ease;
48
+ }
49
+
50
+ .stButton > button:hover {
51
+ background-color: #45a049;
52
+ }
53
+
54
+ /* Adjust subheader margin for better spacing */
55
+ h2 {
56
+ margin-top: 0;
57
+ margin-bottom: 20px;
58
+ color: #333333;
59
+ }
60
+ </style>
61
+ """,
62
+ unsafe_allow_html=True
63
+ )
64
+
65
+ # Create two columns for the cards
66
+ col1, col2 = st.columns(2)
67
+
68
+ # Card 1: Text Input and Button
69
+ with col1:
70
+ st.markdown('<div class="card">', unsafe_allow_html=True)
71
+ st.subheader("Input Section")
72
+
73
+ # Text input
74
+ user_input = st.text_input("Enter your text here:", key="input_text_card1")
75
+
76
+ # Button
77
+ if st.button("Process Text", key="process_button_card1"):
78
+ st.write(f"You entered: **{user_input}**")
79
+ st.success("Text processed successfully!")
80
+
81
+ st.markdown('</div>', unsafe_allow_html=True) # Close card div
82
+
83
+ # Card 2: Placeholder for other content
84
+ with col2:
85
+ st.markdown('<div class="card">', unsafe_allow_html=True)
86
+ st.subheader("Output/Display Section")
87
+ st.write("This card can be used to display results, information, or other widgets.")
88
+ st.write("For example, you could show a chart, an image, or more text here.")
89
+ st.info("This is a placeholder for your content.")
90
+ st.markdown('</div>', unsafe_allow_html=True) # Close card div