Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazing Stuff #4

Open
Lucid-Will opened this issue Mar 7, 2024 · 1 comment
Open

Amazing Stuff #4

Lucid-Will opened this issue Mar 7, 2024 · 1 comment

Comments

@Lucid-Will
Copy link

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

  • Operating System: Microsoft Fabric spark notebook (similar to Synapse Spark notebook)
  • Python Version: 3.10
  • Apache Spark Version: 3.4.1
  • Python packages:
    • Name: qgridnext - Version: 2.0.0
    • Name: pandas - Version: 2.0.3
    • Name: ipywidgets - Version: 8.0.7

Description of Issue

  • What did you expect to happen?
    • Package functions as expected with the exception of a recurring error in the environment. It doesn't seem to negatively impact the expected output.
  • What happened instead?
    • See attached image for error

Reproduction Steps

  1. Launch notebook in Microsoft Fabric data engineering enviornment
  2. Paste provided code and execute
  3. Wait for error to begin prompting in notifications (will happen quite frequently)
    ...

What steps have you taken to resolve this already?

Isolated the issue in standalone notebook to reproduce
...

Anything else?

!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)

image
...

@zhihanyue
Copy link
Owner

This may be related to jupyter-widgets/ipywidgets#3735. Can you upgrade ipywidgets to v8.1.1+ to see if the error still exists?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants