-
Notifications
You must be signed in to change notification settings - Fork 425
Description
Environment
You won't need this. I show below the lines of code that cause the issue.
Versions
python : 3.6.7.final.0
python-bits : 64
OS : Linux
OS-release : 4.14.193-149.317.amzn2.x86_64
machine : x86_64
processor : x86_64
qgrid :1.3.1
notebook: 6.1.3
jupyterlab:2.2.0
jupyterlab-launcher:0.13.1
jupyterlab-pygments:0.1.1
jupyterlab-server:1.2.0
Jupyter lab packages
@bokeh/jupyter_bokeh v2.0.3 enabled OK
@jupyter-widgets/jupyterlab-manager v2.0.0 enabled OK
@jupyterlab/hub-extension v2.2.0 enabled OK
@pyviz/jupyterlab_pyviz v1.0.4 enabled OK
jupyterlab-drawio v0.7.0 enabled OK
qgrid2 v1.1.3 enabled OK
Description of Issue
Widgets created using show_grid without specifying grid_options share a grid_option dict instance, such that changing an option for one will change it for the others.
Reproduction Steps
This will happen for any grid_option item.
In [2]: grid1 = qgrid.show_grid(pd.DataFrame({'a':[1]}))
grid2 = qgrid.show_grid(pd.DataFrame({'c':[5]}))
grid1.grid_options["maxVisibleRows"]
Out [2]: 15
In [3]: grid2.grid_options["maxVisibleRows"]
Out [3]: 15
In [4]: grid1.change_grid_option("maxVisibleRows", 9)
grid1.grid_options["maxVisibleRows"]
Out [4]: 9
In [5]: grid2.grid_options["maxVisibleRows"]
Out [5]: 9
What steps have you taken to resolve this already?
This happens because new qgrid widgets instances are assigned the default grid_options
dict, not a copy of that dict, within show_grid()
, if the call doesn't include an argument for grid_options
Lines 484 to 493 in 877b420
if grid_options is None: | |
grid_options = defaults.grid_options | |
else: | |
options = defaults.grid_options.copy() | |
options.update(grid_options) | |
grid_options = options | |
if not isinstance(grid_options, dict): | |
raise TypeError( | |
"grid_options must be dict, not %s" % type(grid_options) | |
) |