Harshitn24 commited on
Commit
98fb261
1 Parent(s): f845f51

Upload 2 files

Browse files
Files changed (2) hide show
  1. Bengaluru_House_Data.csv +0 -0
  2. app.py +107 -0
Bengaluru_House_Data.csv ADDED
The diff for this file is too large to render. See raw diff
 
app.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tkinter as tk
2
+ from tkinter import ttk
3
+ import pandas as pd
4
+
5
+ # Create the main application window
6
+ root = tk.Tk()
7
+ root.title("Select Box Example")
8
+ root.geometry("300x250")
9
+
10
+ # Define the options for the select boxes
11
+ options1 = ["Low", "Medium", "High"]
12
+ options2 = ["Option A", "Option B", "Option C"]
13
+ options3 = ["Choice X", "Choice Y", "Choice Z"]
14
+
15
+ # Function to handle selection changes
16
+ def on_select(event):
17
+ print("Selected:", combo1.get(), combo2.get(), combo3.get())
18
+
19
+ # Create and place the first label and select box
20
+ label1 = tk.Label(root, text="Growth")
21
+ label1.pack(pady=(10, 0)) # Add padding at the top
22
+ combo1 = ttk.Combobox(root, values=options1)
23
+ combo1.set("Select an option") # Set default text
24
+ combo1.pack(pady=(0, 10)) # Add padding at the bottom
25
+
26
+ # Create and place the second label and select box
27
+ label2 = tk.Label(root, text="Income")
28
+ label2.pack(pady=(10, 0)) # Add padding at the top
29
+ combo2 = ttk.Combobox(root, values=options2)
30
+ combo2.set("Select an option") # Set default text
31
+ combo2.pack(pady=(0, 10)) # Add padding at the bottom
32
+
33
+ # Create and place the third label and select box
34
+ label3 = tk.Label(root, text="Budget")
35
+ label3.pack(pady=(10, 0)) # Add padding at the top
36
+ combo3 = ttk.Combobox(root, values=options3)
37
+ combo3.set("Select an option") # Set default text
38
+ combo3.pack(pady=(0, 10)) # Add padding at the bottom
39
+
40
+ # Bind the select boxes to the on_select function
41
+ combo1.bind("<<ComboboxSelected>>", on_select)
42
+ combo2.bind("<<ComboboxSelected>>", on_select)
43
+ combo3.bind("<<ComboboxSelected>>", on_select)
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()