Skip to content

Commit cf44309

Browse files
authored
Update README.md
1 parent 7a53099 commit cf44309

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

README.md

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
1+
# Jupyter Clickable Image Widget
12

2-
# jupyter_clickable_image_widget
3+
This repository contains an image widget (much like the ipywidgets.Image), but will send messages when the image is clicked.
34

4-
[![Build Status](https://travis-ci.org/jaybdub/jupyter_clickable_image_widget.svg?branch=master)](https://travis-ci.org/jaybdub/jupyter_clickable_image_widget)
5-
[![codecov](https://codecov.io/gh/jaybdub/jupyter_clickable_image_widget/branch/master/graph/badge.svg)](https://codecov.io/gh/jaybdub/jupyter_clickable_image_widget)
5+
# Setup
66

7-
8-
A clickable image widget for Jupyter.
9-
10-
## Installation
11-
12-
You can install using `pip`:
7+
To install the widget type the following in a terminal
138

149
```bash
15-
pip install jupyter_clickable_image_widget
10+
sudo npm install -g typescript
11+
git clone https://github.com/jaybdub/jupyter_clickable_image_widget
12+
cd jupyter_clickable_image_widget
13+
sudo python3 setup.py build
14+
sudo npm run build
15+
sudo pip3 install .
16+
sudo jupyter labextension install .
17+
sudo jupyter labextension install @jupyter-widgets/jupyterlab-manager
1618
```
1719

18-
Or if you use jupyterlab:
20+
# Usage
1921

20-
```bash
21-
pip install jupyter_clickable_image_widget
22-
jupyter labextension install @jupyter-widgets/jupyterlab-manager
23-
```
22+
```python
23+
from jupyter_clickable_image_widget import ClickableImageWidget
2424

25-
If you are using Jupyter Notebook 5.2 or earlier, you may also need to enable
26-
the nbextension:
27-
```bash
28-
jupyter nbextension enable --py [--sys-prefix|--user|--system] jupyter_clickable_image_widget
25+
26+
image_widget = ClickableImageWidget()
27+
28+
def on_message(_, content, _):
29+
if content['event'] == 'click':
30+
data = content['eventData']
31+
alt_key = data['altKey']
32+
ctrl_key = data['ctrlKey']
33+
shift_key = data['shiftKey']
34+
x = data['offsetX']
35+
y = data['offsetY']
36+
37+
# do something...
38+
39+
image_widget.on_msg(on_message)
2940
```

0 commit comments

Comments
 (0)