Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,107 +1,44 @@
|
|
1 |
-
import
|
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 |
-
|
45 |
-
# # Start the main event loop
|
46 |
-
# root.mainloop()
|
47 |
-
|
48 |
-
|
49 |
-
# import tkinter as tk
|
50 |
-
# from tkinter import ttk
|
51 |
-
# import pandas as pd
|
52 |
-
|
53 |
-
# Load data from a CSV file
|
54 |
-
csv_file = 'Bengaluru_House_Data.csv' # Replace with your CSV file path
|
55 |
-
df = pd.read_csv(csv_file)
|
56 |
-
|
57 |
-
# Create the main application window
|
58 |
-
# root = tk.Tk()
|
59 |
-
# root.title("CSV Data Table")
|
60 |
-
|
61 |
-
style = ttk.Style()
|
62 |
-
style.configure("Treeview",
|
63 |
-
background="white",
|
64 |
-
foreground="black",
|
65 |
-
fieldbackground="white",
|
66 |
-
bordercolor="black",
|
67 |
-
borderwidth=2)
|
68 |
-
style.configure("Treeview.Heading",
|
69 |
-
background="lightblue",
|
70 |
-
foreground="black",
|
71 |
-
font=('Arial', 10, 'bold'))
|
72 |
-
|
73 |
-
style.map('Treeview',
|
74 |
-
background=[('selected', 'blue')],
|
75 |
-
foreground=[('selected', 'white')])
|
76 |
-
style.layout("Treeview", [('Treeview.treearea', {'sticky': 'nswe'})])
|
77 |
-
# Create a frame for the table
|
78 |
-
frame = ttk.Frame(root)
|
79 |
-
frame.pack(fill=tk.BOTH, expand=True)
|
80 |
-
|
81 |
-
# Create a Treeview widget
|
82 |
-
tree = ttk.Treeview(frame, columns=list(df.columns), show='headings')
|
83 |
-
|
84 |
-
# Define the column headings
|
85 |
-
for col in df.columns:
|
86 |
-
tree.heading(col, text=col)
|
87 |
-
tree.column(col, anchor=tk.CENTER, width=100)
|
88 |
-
|
89 |
-
# Add the data to the table
|
90 |
-
for index, row in df.iterrows():
|
91 |
-
tree.insert("", tk.END, values=list(row))
|
92 |
-
|
93 |
-
# Add a vertical scrollbar
|
94 |
-
vsb = ttk.Scrollbar(frame, orient="vertical", command=tree.yview)
|
95 |
-
tree.configure(yscrollcommand=vsb.set)
|
96 |
-
vsb.pack(side='right', fill='y')
|
97 |
-
|
98 |
-
# Add a horizontal scrollbar
|
99 |
-
hsb = ttk.Scrollbar(frame, orient="horizontal", command=tree.xview)
|
100 |
-
tree.configure(xscrollcommand=hsb.set)
|
101 |
-
hsb.pack(side='bottom', fill='x')
|
102 |
-
|
103 |
-
# Pack the Treeview widget
|
104 |
-
tree.pack(fill=tk.BOTH, expand=True)
|
105 |
-
|
106 |
-
# Start the main event loop
|
107 |
-
root.mainloop()
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
# Load data from a CSV file
|
5 |
+
csv_file = 'Bengaluru_House_Data.csv' # Replace with your CSV file path
|
6 |
+
df = pd.read_csv(csv_file)
|
7 |
+
|
8 |
+
# Set the title of the web app
|
9 |
+
st.title("CSV Data Table and Select Boxes Example")
|
10 |
+
|
11 |
+
# Define the options for the select boxes
|
12 |
+
options1 = ["Low", "Medium", "High"]
|
13 |
+
options2 = ["Option A", "Option B", "Option C"]
|
14 |
+
options3 = ["Choice X", "Choice Y", "Choice Z"]
|
15 |
+
|
16 |
+
# Create the select boxes
|
17 |
+
growth = st.selectbox("Growth", options1, index=0)
|
18 |
+
income = st.selectbox("Income", options2, index=0)
|
19 |
+
budget = st.selectbox("Budget", options3, index=0)
|
20 |
+
|
21 |
+
# Function to handle selection changes
|
22 |
+
st.write(f"Selected Growth: {growth}")
|
23 |
+
st.write(f"Selected Income: {income}")
|
24 |
+
st.write(f"Selected Budget: {budget}")
|
25 |
+
|
26 |
+
# Display the dataframe as a table
|
27 |
+
st.dataframe(df)
|
28 |
+
|
29 |
+
# Optionally, you can add some styling
|
30 |
+
st.markdown("""
|
31 |
+
<style>
|
32 |
+
.stDataFrame {
|
33 |
+
border: 2px solid black;
|
34 |
+
}
|
35 |
+
.stDataFrame thead th {
|
36 |
+
background-color: lightblue;
|
37 |
+
font-weight: bold;
|
38 |
+
color: black;
|
39 |
+
}
|
40 |
+
.stDataFrame tbody td {
|
41 |
+
border: 1px solid black;
|
42 |
+
}
|
43 |
+
</style>
|
44 |
+
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|