import streamlit as st import pandas as pd import streamlit.components.v1 as components # Load the Excel file file_path = 'Dhaka Metro Rail Fare 2.XLSX' # Ensure the correct file path df = pd.read_excel(file_path) # Ensure necessary columns are present required_columns = ['Origin', 'Destination', 'Fare (৳)'] if not all(col in df.columns for col in required_columns): st.write("Please ensure the file contains 'Origin', 'Destination', and 'Fare' columns.") else: # Streamlit UI setup st.title("Dhaka Metro Rail Fare Checker 🚇") st.write("Below is the fare chart for Dhaka Metro Rail 💶:") # Instruction sidebar st.sidebar.title("Instructions") st.sidebar.write(""" **Welcome to the Dhaka Metro Rail Fare Checker! 🚇** *How to use:* 1. **Select your Location station**: - Choose the station you are currently at from the **"Select your Location"** dropdown menu. 2. **Select your destination(s)**: - After selecting your origin station, you will see a list of available destination stations. - Click on the **destination buttons** for the station(s) you wish to travel to. - You can select multiple destinations to check fares for different routes at once. 3. **Fare Calculation**: - The fare from your selected origin station to each of the selected destination(s) will be displayed below in the fare details section. 4. **Clear Destinations**: - If you want to reset your selection of destinations, simply click the **"Clear All Destinations"** button to start fresh. --- **Interactive Map**: The interactive map of Dhaka Metro stations below allows you to visualize routes between your selected origin and destination(s). Use the map to explore stations, animate routes, and check locations on the map. **Interactive Features**: - **Source & Destination Dropdown**: Select your source and destination from the dropdown menus on the map. - **Animate Route**: Click the **"Animate Route"** button to visually track the route between the selected source and destination stations. - **Animate All Locations**: Click the **"Animate All Locations"** button to animate all stations and get a dynamic overview of the network. - **Stop Animation**: If you want to stop the animation at any time, press the **"Stop Animation"** button. Enjoy your journey on the Dhaka Metro! 🚉 If you encounter any issues or need assistance, feel free to [Contact Support on WhatsApp](https://wa.me/+8801719296601). """) # Define the default "Select Journey from" message default_origin = "Select Journey from" # Dropdown for selecting origin (with "Select Journey from" as a default placeholder) origin = st.selectbox( "Select your Location:", [default_origin] + df['Origin'].unique().tolist(), # Add the "Select Journey from" option at the top index=0 # Ensure the first option is selected by default ) # Initialize session state for destination selection if not already set if 'destination_select' not in st.session_state: st.session_state.destination_select = [] # Display buttons for each destination in 3 columns if origin != default_origin: st.write(f"Select your destination(s) from {origin}:") # Create 3 columns cols = st.columns(3) # Loop through all possible destinations and create a button for each in the columns dest_buttons = df['Destination'].unique() for i, dest in enumerate(dest_buttons): col_idx = i % 3 # Determine column index based on button position with cols[col_idx]: if st.button(f"Select {dest}", key=f"btn_{dest}"): if dest not in st.session_state.destination_select: st.session_state.destination_select.append(dest) else: st.session_state.destination_select.remove(dest) # Clear all selected destinations button if st.button("Clear All Destinations"): st.session_state.destination_select = [] # Display selected destinations and calculate fares destinations = st.session_state.destination_select if origin == default_origin: st.write("Please select a valid origin station to proceed.") elif origin and destinations: # Filter the dataframe based on user selection fare_data = df[(df['Origin'] == origin) & (df['Destination'].isin(destinations))] # Display the fare data # Display the fare data in a creative and aesthetic format if not fare_data.empty: for index, row in fare_data.iterrows(): origin_to_dest_fare = row['Fare (৳)'] destination = row['Destination'] # Creative output with icons, emojis, and styled text fare_message = f"""

🚇 {origin} to {destination} Fare

💵 Fare: {origin_to_dest_fare}৳

✨ Enjoy your journey on the Dhaka Metro! 🚉

""" st.markdown(fare_message, unsafe_allow_html=True) else: st.write("No fare data available for the selected origin and destinations.") else: st.write("Please select both an origin and at least one destination.") # Embedding the interactive map st.write("### Interactive Map of Dhaka Metro Stations") map_html = """ Interactive Map
""" components.html(map_html, height=600)