File: gui_notifications.py

package info (click to toggle)
napari 0.6.6-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 12,036 kB
  • sloc: python: 112,264; xml: 72; makefile: 44; sh: 5
file content (26 lines) | stat: -rw-r--r-- 625 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import warnings

import napari
from napari._qt.widgets.qt_viewer_buttons import QtViewerPushButton


def raise_():
    x = 1
    y = 'a string'
    import something_that_does_not_exist
    return something_that_does_not_exist.fun(x, y)


def warn_():
    warnings.warn('warning!')


viewer = napari.Viewer()
layer_buttons = viewer.window._qt_viewer.layerButtons
err_btn = QtViewerPushButton('warning', 'new Error', raise_)
warn_btn = QtViewerPushButton('warning', 'new Warn', warn_)
layer_buttons.layout().insertWidget(3, warn_btn)
layer_buttons.layout().insertWidget(3, err_btn)

if __name__ == '__main__':
    napari.run()