# Streamlit Dtale PygWalker compile

**URL:** <https://discuss.streamlit.io/t/streamlit-dtale-pygwalker-compile/64962>\
**Category:** Using Streamlit\
**Tags:** discussion\
**Created:** [March 18, 2024, 6:54am UTC](https://discuss.streamlit.io/t/streamlit-dtale-pygwalker-compile/64962 "2024-03-18T06:54:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tjsxstreamlit](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@tjsxstreamlit](https://discuss.streamlit.io/u/tjsxstreamlit)\
**Post date:** [March 18, 2024, 6:54am UTC](https://discuss.streamlit.io/t/streamlit-dtale-pygwalker-compile/64962/1 "2024-03-18T06:54:17Z")

</div>

```auto
import streamlit as st
import pandas as pd
import dtale
import pygwalker as pygwalk
import threading

# Function to read the Titanic dataset
def read_titanic_data():
    # Assuming the CSV file is named 'titanic.csv' and located in the same directory as your Python script
    # If the file is located in a different directory, provide the full path to the file
    titanic_df = pd.read_csv('titanic.csv')
    return titanic_df

# Function to display data using dtale
def display_with_dtale(data):
    dtale_instance = dtale.show(data)
    return dtale_instance

# Function to start pygwalk server in a separate thread
def start_pygwalk_server(data):
    pygwalk.show(data)

def main():
    st.title('Visualization Tools for Titanic Dataset')

    # Read the Titanic dataset
    data = read_titanic_data()

    # Create radio buttons for visualization tools
    visualization_tool = st.radio("Choose Visualization Tool", ["dtale", "pygwalk"], horizontal=True)

    if visualization_tool == "dtale":
        st.write("You selected dtale")
        run_button = st.button("Run")
        stop_button = st.button("Stop")
        if run_button:
            if 'dtale_instance' not in st.session_state:
                st.session_state.dtale_instance= dtale.show(data)
            else:
                st.session_state.dtale_instance.kill()
                st.session_state.dtale_instance= dtale.show(data)

            dtale_url = st.session_state.dtale_instance.main_url()
            st.components.v1.html(f'<iframe src="{dtale_url}" width="1000" height="600" style="border:none;"></iframe>', height=700)
        if stop_button and st.session_state.dtale_instance:
            st.session_state.dtale_instance.kill()
            
    elif visualization_tool == "pygwalk":
        st.write("You selected pygwalk")
        run_button = st.button("Run")
        stop_button = st.button("Stop")
        pygwalk_instance = None
        if run_button:
            pygwalk_thread = threading.Thread(target=start_pygwalk_server, args=(data,))
            pygwalk_thread.start()
            st.write("Pygwalk server started. Please open the browser and navigate to the provided URL.")
        if stop_button and pygwalk_instance:
            # Currently, pygwalk doesn't provide a direct way to stop the server programmatically
            # You would typically need to stop the server manually (e.g., Ctrl+C in the terminal)
            st.write("To stop pygwalk, please manually stop the server")

if __name__ == " __main__":
    main()

```

---

<div class="post-metadata">

**Author:** ![ObservedObserver](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/observedobserver/32/28618_2.png) [@ObservedObserver](https://discuss.streamlit.io/u/ObservedObserver)\
**Post date:** [March 18, 2024, 10:56am UTC](https://discuss.streamlit.io/t/streamlit-dtale-pygwalker-compile/64962/2 "2024-03-18T10:56:20Z")

</div>

Hi, it seems the code uses some API of pygwalker that does not exist.

You can check this pygwalker example of how to use with streamlit: [How to Use PyGWalker with Streamlit – Nextra](https://pygwalker.kanaries.net/tutorials/use-pygwalker-with-streamlit)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [September 14, 2024, 10:57am UTC](https://discuss.streamlit.io/t/streamlit-dtale-pygwalker-compile/64962/3 "2024-09-14T10:57:16Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
