You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+42-13
Original file line number
Diff line number
Diff line change
@@ -11,14 +11,11 @@ Qgrid is a Jupyter notebook widget which uses `SlickGrid <https://github.com/mle
11
11
DataFrames within a Jupyter notebook. This allows you to explore your DataFrames with intuitive scrolling, sorting, and
12
12
filtering controls, as well as edit your DataFrames by double clicking cells.
13
13
14
-
We originally developed qgrid for use in `Quantopian's hosted research environment
15
-
<https://www.quantopian.com/research?utm_source=github&utm_medium=web&utm_campaign=qgrid-repo>`_ in fall of 2014, but
16
-
had to put it on the backburner for a while so we could focus on higher priority projects.
14
+
What's New in 1.0.3 - Introducing Qgrid Events
15
+
----------------------------------------------
16
+
Qgrid has some new API methods as of version 1.0.3 which can be used to attach event handlers. Event handlers are callback methods that get called when certain events occur in the qgrid interface. In qgrid 1.0.3, event handlers can be attached with the ``on`` method and detached with the ``off`` method. There are ``on`` and ``off`` methods on both the ``qgrid`` module (see `qgrid.on <https://qgrid.readthedocs.io/en/latest/#qgrid.on>`_), and on individual QgridWidget instances (see `qgrid.QgridWidget.on <https://qgrid.readthedocs.io/en/latest/#qgrid.QgridWidget.on>`_).
17
17
18
-
Qgrid development started up again in summer 2017, when we started a major refactoring project to allow qgrid to take
19
-
advantage of the latest advances in ipywidgets (specifically, ipywidget 7.x). As a part of this refactoring we also
20
-
moved qgrid's sorting, and filtering logic from the client (javascript) to the server (python). This new version is
21
-
called qgrid 1.0, and the instructions that follow are for this new version.
18
+
To get a better idea of how these methods might be used, see the `Events API`_ section below.
22
19
23
20
Demo
24
21
----
@@ -199,20 +196,52 @@ read-the-docs page, you can preview your changes locally before submitting a PR
199
196
This will result in the ``docs/_build/html`` folder being populated with a new version of the read-the-docs site. If
200
197
you open the ``index.html`` file in your browser, you should be able to preview your changes.
201
198
202
-
Experimental Demo
203
-
-----------------
204
-
As of qgrid 1.0 there are some interesting ways we can use qgrid in conjunction with other widgets/visualizations. One example is using qgrid to filter a DataFrame that's also being displayed by another visualization.
199
+
Events API
200
+
----------
201
+
As of qgrid 1.0.3 there are new ``on`` and ``off`` methods in qgrid which can be used to attach/detach event handlers. Previously the only way to listen for events was to use undocumented parts of the API.
202
+
203
+
Having the ability to attach event handlers allows us to do some interesting things in terms of using qgrid in conjunction with other widgets/visualizations. One example is using qgrid to filter a DataFrame that's also being displayed by another visualization.
204
+
205
+
If you previously used the ``observe`` method to respond to qgrid events, lets see how your code might be updated to use the new ``on`` method::
When you upgrade to 1.0.3, you have more granular control over which events you do an don't listen to, but you can also replicate the previous behavior of calling ``print`` every time the state of the internal DataFrame is changed. Here's what that would look like using the new ``on`` method::
214
+
215
+
# After upgrading to 1.0.3
216
+
def handle_json_updated(event, qgrid_widget):
217
+
# exclude 'viewport_changed' events since that doesn't change the DataFrame
218
+
if (event['triggered_by'] != 'viewport_changed'):
219
+
print(qgrid_widget.get_changed_df())
205
220
206
-
Currently these ways of using qgrid are not documented in the API docs or extensively tested, so they're still considered experimental. See the `experimental notebook <https://beta.mybinder.org/v2/gh/quantopian/qgrid-notebooks/master?filepath=experimental.ipynb>`_ to learn more.
For people who would rather not go to another page to try out the experimental notebook, here's the tldr; version:
223
+
See the `events notebook <https://mybinder.org/v2/gh/quantopian/qgrid-notebooks/master?filepath=events.ipynb>`_ for more examples of using these new API methods.
224
+
225
+
For people who would rather not go to another page to try out the events notebook, here are a couple of gifs to give you an idea of what you can do with it.
226
+
227
+
The first gif shows how you can use qgrid to filter the data that's being shown by a matplotlib scatter plot:
209
228
210
229
.. figure:: docs/images/linked_to_scatter.gif
211
230
:align:left
212
231
:target:docs/images/linked_to_scatter.gif
213
232
:width:600px
214
233
215
-
A brief demo showing filtering, editing, and the `get_changed_df()` method
234
+
A brief demo showing qgrid hooked up to a matplotlib plot
235
+
236
+
The second gif shows how you can move qgrid to a separate view in JupyterLab, which makes it more convenient
237
+
to use in conjunction with other visualizations (in this case, a couple of ``Output`` widgets):
0 commit comments