Skip to content

Commit 78e703e

Browse files
authored
Merge pull request #196 from quantopian/bump-version
Bump version to 1.0.3 (promote beta release to GA)
2 parents 5e12f8f + 733e807 commit 78e703e

File tree

6 files changed

+52
-21
lines changed

6 files changed

+52
-21
lines changed

Diff for: README.rst

+42-13
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@ Qgrid is a Jupyter notebook widget which uses `SlickGrid <https://github.com/mle
1111
DataFrames within a Jupyter notebook. This allows you to explore your DataFrames with intuitive scrolling, sorting, and
1212
filtering controls, as well as edit your DataFrames by double clicking cells.
1313

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>`_).
1717

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.
2219

2320
Demo
2421
----
@@ -199,20 +196,52 @@ read-the-docs page, you can preview your changes locally before submitting a PR
199196
This will result in the ``docs/_build/html`` folder being populated with a new version of the read-the-docs site. If
200197
you open the ``index.html`` file in your browser, you should be able to preview your changes.
201198

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::
206+
207+
# Before upgrading to 1.0.3
208+
def handle_df_change(change):
209+
print(change['new'])
210+
211+
qgrid_widget.observe(handle_df_change, names=['_df'])
212+
213+
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())
205220

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.
221+
qgrid_widget.on('json_updated', handle_json_updated)
207222

208-
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:
209228

210229
.. figure:: docs/images/linked_to_scatter.gif
211230
:align: left
212231
:target: docs/images/linked_to_scatter.gif
213232
:width: 600px
214233

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):
238+
239+
.. figure:: docs/images/events_api.gif
240+
:align: left
241+
:target: docs/images/events_api.gif
242+
:width: 600px
243+
244+
A brief demo showing qgrid's events api
216245

217246
Continuing to use qgrid 0.3.3
218247
-----------------------------

Diff for: docs/images/events_api.gif

33.6 MB
Loading

Diff for: js/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "qgrid",
3-
"version": "1.0.3-beta.0",
3+
"version": "1.0.3",
44
"description": "An Interactive Grid for Sorting and Filtering DataFrames in Jupyter Notebook",
55
"author": "Quantopian Inc.",
66
"main": "src/index.js",

Diff for: js/src/qgrid.widget.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class QgridModel extends widgets.DOMWidgetModel {
3636
_view_name : 'QgridView',
3737
_model_module : 'qgrid',
3838
_view_module : 'qgrid',
39-
_model_module_version : '^1.0.3-beta.0',
40-
_view_module_version : '^1.0.3-beta.0',
39+
_model_module_version : '^1.0.3',
40+
_view_module_version : '^1.0.3',
4141
_df_json: '',
4242
_columns: {}
4343
});

Diff for: qgrid/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version_info = (1, 0, 3, 'beta', 0)
1+
version_info = (1, 0, 3, 'final')
22

33
_specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''}
44

Diff for: qgrid/grid.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def on(names, handler):
172172
173173
The reason it's not available on individual qgrid instances is because
174174
the only time it fires is when a new instance is created. This means
175-
it's already donefiring by the time a user has a chance to hook up any
175+
it's already done firing by the time a user has a chance to hook up any
176176
event listeners.
177177
178178
Here's the full list of events that can be listened for via this
@@ -464,8 +464,8 @@ class QgridWidget(widgets.DOMWidget):
464464
_model_name = Unicode('QgridModel').tag(sync=True)
465465
_view_module = Unicode('qgrid').tag(sync=True)
466466
_model_module = Unicode('qgrid').tag(sync=True)
467-
_view_module_version = Unicode('1.0.3-beta.0').tag(sync=True)
468-
_model_module_version = Unicode('1.0.3-beta.0').tag(sync=True)
467+
_view_module_version = Unicode('1.0.3').tag(sync=True)
468+
_model_module_version = Unicode('1.0.3').tag(sync=True)
469469

470470
_df = Instance(pd.DataFrame)
471471
_df_json = Unicode('', sync=True)
@@ -588,7 +588,9 @@ def on(self, names, handler):
588588
effect of certain actions such as scrolling, sorting, and filtering.
589589
590590
* **triggered_by** The name of the event that resulted in rows of
591-
data being sent down to the browser.
591+
data being sent down to the browser. Possible values are
592+
``viewport_changed``, ``filter_changed``, ``sort_changed``,
593+
``add_row``, and ``remove_row``.
592594
* **range** A tuple specifying the range of rows that have been
593595
sent down to the browser.
594596

0 commit comments

Comments
 (0)