Skip to content

Commit c6e1736

Browse files
committed
Add widget live-refresh functionality with toolbar button
1 parent 8dd21b5 commit c6e1736

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/widget.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { Widget } from '@lumino/widgets';
2-
import { MainAreaWidget } from '@jupyterlab/apputils';
2+
import {
3+
MainAreaWidget,
4+
ToolbarButton,
5+
} from '@jupyterlab/apputils';
36
import {
47
imageIcon,
8+
refreshIcon,
59
} from '@jupyterlab/ui-components';
610

711
import { requestAPI } from './request';
@@ -60,5 +64,15 @@ export class ImageCaptionMainAreaWidget extends MainAreaWidget<ImageCaptionWidge
6064
this.title.label = 'Random image with caption';
6165
this.title.caption = this.title.label;
6266
this.title.icon = imageIcon;
67+
68+
// Add a refresh button to the toolbar
69+
const refreshButton = new ToolbarButton({
70+
icon: refreshIcon,
71+
tooltip: 'Refresh image',
72+
onClick: () => {
73+
widget.load_image();
74+
}
75+
});
76+
this.toolbar.addItem('refresh', refreshButton);
6377
}
6478
}

0 commit comments

Comments
 (0)