<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Issue with clear_output() Method in ipywidgets within ArcPro Notebooks in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/issue-with-clear-output-method-in-ipywidgets/m-p/1483213#M84070</link>
    <description>&lt;P&gt;Dear Esri Support,&lt;/P&gt;&lt;P&gt;I am a federal government user running ArcPro notebooks in a completely disconnected environment. We use ipywidgets in our notebooks to build UI interfaces that allow analysts to run tools repeatedly without needing coding skills.&lt;/P&gt;&lt;P&gt;I am currently working on a tool that as part of its outputs is a Pandas DataFrame. This tool enables users to quickly modify variables using dropdowns and other widgets. Since the tool is run repeatedly, the previous output needs to be cleared and replaced with the new output, but persist the ui created using ipywidgets, each time it is executed.&lt;/P&gt;&lt;P&gt;To achieve this, I load the output into an ipywidget output widget and use the clear_output() method. According to the documentation, multiple defined outputs can be targeted individually.&lt;/P&gt;&lt;P&gt;In my use case, I use these output widgets to build the UI and to display the output to the user running the tool. However, I have observed that in ArcPro notebooks, running clear_output on a single output widget clears all output widgets. I have tested this in a notebook running in a notebook server, where clear_output works as documented and only clears the specified output.&lt;/P&gt;&lt;P&gt;Here is a code snippet that demonstrates this issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import&lt;/STRONG&gt; ipywidgets &lt;STRONG&gt;as&lt;/STRONG&gt; widgets&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from&lt;/STRONG&gt; IPython.display &lt;STRONG&gt;import&lt;/STRONG&gt; display&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import&lt;/STRONG&gt; pandas &lt;STRONG&gt;as&lt;/STRONG&gt; pd&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import&lt;/STRONG&gt; time&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Create Output widgets&lt;/P&gt;&lt;P&gt;df_output = widgets.Output()&lt;/P&gt;&lt;P&gt;text_output = widgets.Output()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Display the Output widgets&lt;/P&gt;&lt;P&gt;display(text_output)&lt;/P&gt;&lt;P&gt;display(df_output)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Display the persistent text in the text_output widget&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;with&lt;/STRONG&gt; text_output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;print&lt;/STRONG&gt;("This text persists across DataFrame changes")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Create and display the initial DataFrame&lt;/P&gt;&lt;P&gt;df = pd.DataFrame({&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'A': [1, 2, 3],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'B': [4, 5, 6]&lt;/P&gt;&lt;P&gt;})&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Function to display a DataFrame in the df_output widget&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;def&lt;/STRONG&gt; display_dataframe(dataframe):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;with&lt;/STRONG&gt; df_output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; display(dataframe)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Function to update the DataFrame and display in the df_output widget&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;def&lt;/STRONG&gt; update_display():&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Clear the output widget&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; df_output.clear_output(wait=True)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create and display the updated DataFrame&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; display_dataframe(df)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Display the initial DataFrame&lt;/P&gt;&lt;P&gt;update_display()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Wait for 2 seconds to visualize the initial DataFrame&lt;/P&gt;&lt;P&gt;time.sleep(2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Update the DataFrame&lt;/P&gt;&lt;P&gt;df = pd.DataFrame({&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'A': [7, 8, 9],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'B': [10, 11, 12]&lt;/P&gt;&lt;P&gt;})&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Update the display&lt;/P&gt;&lt;P&gt;update_display()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Wait for 2 seconds to visualize the updated DataFrame&lt;/P&gt;&lt;P&gt;time.sleep(2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Update the DataFrame again&lt;/P&gt;&lt;P&gt;df = pd.DataFrame({&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'A': [13, 14, 15],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'B': [16, 17, 18]&lt;/P&gt;&lt;P&gt;})&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Update the display&lt;/P&gt;&lt;P&gt;update_display()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the code, I define an output that contains a text header (simulating a UI element that needs to persist across tool runs) and another output that loads several Pandas DataFrames. In an ArcPro notebook, the text header never displays because calling clear_output on the widget containing the DataFrames clears all output. In a notebook server notebook, the text header persists while the DataFrames change as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate your assistance in resolving this issue.&lt;BR /&gt;&lt;BR /&gt;UPDATE:&amp;nbsp; Using Arc Pro 3.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Jun 2024 13:44:32 GMT</pubDate>
    <dc:creator>SteveF</dc:creator>
    <dc:date>2024-06-03T13:44:32Z</dc:date>
    <item>
      <title>Issue with clear_output() Method in ipywidgets within ArcPro Notebooks</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/issue-with-clear-output-method-in-ipywidgets/m-p/1483213#M84070</link>
      <description>&lt;P&gt;Dear Esri Support,&lt;/P&gt;&lt;P&gt;I am a federal government user running ArcPro notebooks in a completely disconnected environment. We use ipywidgets in our notebooks to build UI interfaces that allow analysts to run tools repeatedly without needing coding skills.&lt;/P&gt;&lt;P&gt;I am currently working on a tool that as part of its outputs is a Pandas DataFrame. This tool enables users to quickly modify variables using dropdowns and other widgets. Since the tool is run repeatedly, the previous output needs to be cleared and replaced with the new output, but persist the ui created using ipywidgets, each time it is executed.&lt;/P&gt;&lt;P&gt;To achieve this, I load the output into an ipywidget output widget and use the clear_output() method. According to the documentation, multiple defined outputs can be targeted individually.&lt;/P&gt;&lt;P&gt;In my use case, I use these output widgets to build the UI and to display the output to the user running the tool. However, I have observed that in ArcPro notebooks, running clear_output on a single output widget clears all output widgets. I have tested this in a notebook running in a notebook server, where clear_output works as documented and only clears the specified output.&lt;/P&gt;&lt;P&gt;Here is a code snippet that demonstrates this issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import&lt;/STRONG&gt; ipywidgets &lt;STRONG&gt;as&lt;/STRONG&gt; widgets&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from&lt;/STRONG&gt; IPython.display &lt;STRONG&gt;import&lt;/STRONG&gt; display&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import&lt;/STRONG&gt; pandas &lt;STRONG&gt;as&lt;/STRONG&gt; pd&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import&lt;/STRONG&gt; time&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Create Output widgets&lt;/P&gt;&lt;P&gt;df_output = widgets.Output()&lt;/P&gt;&lt;P&gt;text_output = widgets.Output()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Display the Output widgets&lt;/P&gt;&lt;P&gt;display(text_output)&lt;/P&gt;&lt;P&gt;display(df_output)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Display the persistent text in the text_output widget&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;with&lt;/STRONG&gt; text_output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;print&lt;/STRONG&gt;("This text persists across DataFrame changes")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Create and display the initial DataFrame&lt;/P&gt;&lt;P&gt;df = pd.DataFrame({&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'A': [1, 2, 3],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'B': [4, 5, 6]&lt;/P&gt;&lt;P&gt;})&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Function to display a DataFrame in the df_output widget&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;def&lt;/STRONG&gt; display_dataframe(dataframe):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;with&lt;/STRONG&gt; df_output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; display(dataframe)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Function to update the DataFrame and display in the df_output widget&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;def&lt;/STRONG&gt; update_display():&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Clear the output widget&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; df_output.clear_output(wait=True)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create and display the updated DataFrame&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; display_dataframe(df)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Display the initial DataFrame&lt;/P&gt;&lt;P&gt;update_display()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Wait for 2 seconds to visualize the initial DataFrame&lt;/P&gt;&lt;P&gt;time.sleep(2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Update the DataFrame&lt;/P&gt;&lt;P&gt;df = pd.DataFrame({&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'A': [7, 8, 9],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'B': [10, 11, 12]&lt;/P&gt;&lt;P&gt;})&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Update the display&lt;/P&gt;&lt;P&gt;update_display()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Wait for 2 seconds to visualize the updated DataFrame&lt;/P&gt;&lt;P&gt;time.sleep(2)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Update the DataFrame again&lt;/P&gt;&lt;P&gt;df = pd.DataFrame({&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'A': [13, 14, 15],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'B': [16, 17, 18]&lt;/P&gt;&lt;P&gt;})&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Update the display&lt;/P&gt;&lt;P&gt;update_display()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the code, I define an output that contains a text header (simulating a UI element that needs to persist across tool runs) and another output that loads several Pandas DataFrames. In an ArcPro notebook, the text header never displays because calling clear_output on the widget containing the DataFrames clears all output. In a notebook server notebook, the text header persists while the DataFrames change as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate your assistance in resolving this issue.&lt;BR /&gt;&lt;BR /&gt;UPDATE:&amp;nbsp; Using Arc Pro 3.1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2024 13:44:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/issue-with-clear-output-method-in-ipywidgets/m-p/1483213#M84070</guid>
      <dc:creator>SteveF</dc:creator>
      <dc:date>2024-06-03T13:44:32Z</dc:date>
    </item>
  </channel>
</rss>

