Spaces:
Sleeping
Sleeping
Update app.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107import tkinter as tkfrom tkinter import ttkimport pandas as pd# Create the main application windowroot = tk.Tk()root.title("Select Box Example")root.geometry("300x250")# Define the options for the select boxesoptions1 = ["Low", "Medium", "High"]options2 = ["Option A", "Option B", "Option C"]options3 = ["Choice X", "Choice Y", "Choice Z"]# Function to handle selection changesdef on_select(event):print("Selected:", combo1.get(), combo2.get(), combo3.get())# Create and place the first label and select boxlabel1 = tk.Label(root, text="Growth")label1.pack(pady=(10, 0)) # Add padding at the topcombo1 = ttk.Combobox(root, values=options1)combo1.set("Select an option") # Set default textcombo1.pack(pady=(0, 10)) # Add padding at the bottom# Create and place the second label and select boxlabel2 = tk.Label(root, text="Income")label2.pack(pady=(10, 0)) # Add padding at the topcombo2 = ttk.Combobox(root, values=options2)combo2.set("Select an option") # Set default textcombo2.pack(pady=(0, 10)) # Add padding at the bottom# Create and place the third label and select boxlabel3 = tk.Label(root, text="Budget")label3.pack(pady=(10, 0)) # Add padding at the topcombo3 = ttk.Combobox(root, values=options3)combo3.set("Select an option") # Set default textcombo3.pack(pady=(0, 10)) # Add padding at the bottom# Bind the select boxes to the on_select functioncombo1.bind("<<ComboboxSelected>>", on_select)combo2.bind("<<ComboboxSelected>>", on_select)combo3.bind("<<ComboboxSelected>>", on_select)# # Start the main event loop# root.mainloop()# import tkinter as tk# from tkinter import ttk# import pandas as pd# Load data from a CSV filecsv_file = 'Bengaluru_House_Data.csv' # Replace with your CSV file pathdf = pd.read_csv(csv_file)# Create the main application window# root = tk.Tk()# root.title("CSV Data Table")style = ttk.Style()style.configure("Treeview",background="white",foreground="black",fieldbackground="white",bordercolor="black",borderwidth=2)style.configure("Treeview.Heading",background="lightblue",foreground="black",font=('Arial', 10, 'bold'))style.map('Treeview',background=[('selected', 'blue')],foreground=[('selected', 'white')])style.layout("Treeview", [('Treeview.treearea', {'sticky': 'nswe'})])# Create a frame for the tableframe = ttk.Frame(root)frame.pack(fill=tk.BOTH, expand=True)# Create a Treeview widgettree = ttk.Treeview(frame, columns=list(df.columns), show='headings')# Define the column headingsfor col in df.columns:tree.heading(col, text=col)tree.column(col, anchor=tk.CENTER, width=100)# Add the data to the tablefor index, row in df.iterrows():tree.insert("", tk.END, values=list(row))# Add a vertical scrollbarvsb = ttk.Scrollbar(frame, orient="vertical", command=tree.yview)tree.configure(yscrollcommand=vsb.set)vsb.pack(side='right', fill='y')# Add a horizontal scrollbarhsb = ttk.Scrollbar(frame, orient="horizontal", command=tree.xview)tree.configure(xscrollcommand=hsb.set)hsb.pack(side='bottom', fill='x')# Pack the Treeview widgettree.pack(fill=tk.BOTH, expand=True)# Start the main event looproot.mainloop()1234567891011121314151617181920212223242526272829303132333435363738394041424344import streamlit as stimport pandas as pd# Load data from a CSV filecsv_file = 'Bengaluru_House_Data.csv' # Replace with your CSV file pathdf = pd.read_csv(csv_file)# Set the title of the web appst.title("CSV Data Table and Select Boxes Example")# Define the options for the select boxesoptions1 = ["Low", "Medium", "High"]options2 = ["Option A", "Option B", "Option C"]options3 = ["Choice X", "Choice Y", "Choice Z"]# Create the select boxesgrowth = st.selectbox("Growth", options1, index=0)income = st.selectbox("Income", options2, index=0)budget = st.selectbox("Budget", options3, index=0)# Function to handle selection changesst.write(f"Selected Growth: {growth}")st.write(f"Selected Income: {income}")st.write(f"Selected Budget: {budget}")# Display the dataframe as a tablest.dataframe(df)# Optionally, you can add some stylingst.markdown("""<style>.stDataFrame {border: 2px solid black;}.stDataFrame thead th {background-color: lightblue;font-weight: bold;color: black;}.stDataFrame tbody td {border: 1px solid black;}</style>""", unsafe_allow_html=True)
app.py+44-107