import streamlit as st # type: ignore import pandas as pd # type: ignore # Initialize notes dataframe notes_df = pd.DataFrame(columns=['Title', 'Content']) # Function to add a new note def add_note(title, content): new_note = pd.DataFrame({'Title': [title], 'Content': [content]}) global notes_df notes_df = pd.concat([notes_df, new_note], ignore_index=True) # Function to update a note def update_note(index, title, content): global notes_df notes_df.at[index, 'Title'] = title notes_df.at[index, 'Content'] = content # Function to delete a note def delete_note(index): global notes_df notes_df = notes_df.drop(index) # Streamlit app st.title("Note-Taking App") # Create a new note st.header("Create a New Note") title = st.text_input("Title") content = st.text_area("Content") if st.button("Add Note"): add_note(title, content) # Display all notes st.header("All Notes") st.write(notes_df) # Update a note st.header("Update a Note") index = st.selectbox("Select a Note to Update", notes_df.index) if st.button("Update Note"): title = st.text_input("New Title") content = st.text_area("New Content") update_note(index, title, content) # Delete a note st.header("Delete a Note") index = st.selectbox("Select a Note to Delete", notes_df.index) if st.button("Delete Note"): delete_note(index)