Open Lucid-Will opened 6 months ago
First, awesome stuff. Thank you for picking this back up.
I was able to implement pretty easily and have things working as expected with the exception of a recurring error that's thrown in my environment.
Isolated the issue in standalone notebook to reproduce ...
!pip install qgridnext -q import pandas as pd import ipywidgets as widgets from IPython.display import display import qgrid # Set up grid options and column options as you provided grid_options = { 'fullWidthRows': True, 'syncColumnCellResize': True, 'forceFitColumns': True, 'defaultColumnWidth': 150, 'rowHeight': 28, 'enableColumnReorder': False, 'editable': True, 'autoEdit': False, 'explicitInitialization': True, 'enableAddRow': True, 'maxVisibleRows': 25, 'minVisibleRows': 8, 'sortable': True, 'filterable': True, 'highlightSelectedCell': False, 'highlightSelectedRow': True } column_options = { 'editable': True, 'sortable': True, 'resizable': True, } # Sample DataFrame df = pd.DataFrame({ 'Category': ['A', 'B', 'A', 'C'], 'Value': [10, 20, 30, 40] }) # Create dropdown for filtering category_dropdown = widgets.Dropdown( options=['All'] + list(df['Category'].unique()), value='All', description='Category:', ) # Initialize QgridWidget qgrid_widget = qgrid.show_grid(df, show_toolbar=True, grid_options=grid_options, column_options=column_options) # Define a function to filter the grid based on the dropdown selection def filter_grid(change): if change.new == 'All': qgrid_widget.df = df else: qgrid_widget.df = df[df['Category'] == change.new] # Observe changes in dropdown to apply filters category_dropdown.observe(filter_grid, names='value') # Define a button and its callback function for confirming the selection confirm_button = widgets.Button(description='Confirm Selection') def on_confirm_button_clicked(b): selected_df = qgrid_widget.get_changed_df() display(selected_df) confirm_button.on_click(on_confirm_button_clicked) # Display the dropdown, grid widget, and button display(category_dropdown) display(qgrid_widget) display(confirm_button)
...
This may be related to jupyter-widgets/ipywidgets#3735. Can you upgrade ipywidgets to v8.1.1+ to see if the error still exists?
First, awesome stuff. Thank you for picking this back up.
I was able to implement pretty easily and have things working as expected with the exception of a recurring error that's thrown in my environment.
Environment
Description of Issue
Reproduction Steps
What steps have you taken to resolve this already?
Isolated the issue in standalone notebook to reproduce ...
Anything else?