@xvfb_it
@npt.dec.skipif((not actor.have_vtk))
@npt.dec.skipif((not actor.have_vtk_colors))
def test_button_and_slider_widgets():
    interactive = False
    renderer = window.Renderer()
    lines = [np.array([[(- 1), 0, 0.0], [1, 0, 0.0]]), np.array([[(- 1), 1, 0.0], [1, 1, 0.0]])]
    colors = np.array([[1.0, 0.0, 0.0], [0.3, 0.7, 0.0]])
    stream_actor = actor.streamtube(lines, colors)
    renderer.add(stream_actor)
    show_manager = window.ShowManager(renderer, size=(800, 800))
    if interactive:
        show_manager.initialize()
        show_manager.render()

    def button_callback(obj, event):
        print('Camera pressed')

    def button_plus_callback(obj, event):
        print('+ pressed')

    def button_minus_callback(obj, event):
        print('- pressed')
    fetch_viz_icons()
    button_png = read_viz_icons(fname='camera.png')
    button = widget.button(show_manager.iren, show_manager.ren, button_callback, button_png, (0.98, 1.0), (80, 50))
    button_png_plus = read_viz_icons(fname='plus.png')
    button_plus = widget.button(show_manager.iren, show_manager.ren, button_plus_callback, button_png_plus, (0.98, 0.9), (120, 50))
    button_png_minus = read_viz_icons(fname='minus.png')
    button_minus = widget.button(show_manager.iren, show_manager.ren, button_minus_callback, button_png_minus, (0.98, 0.9), (50, 50))

    def print_status(obj, event):
        rep = obj.GetRepresentation()
        stream_actor.SetPosition((rep.GetValue(), 0, 0))
    slider = widget.slider(show_manager.iren, show_manager.ren, callback=print_status, min_value=(- 1), max_value=1, value=0.0, label='X', right_normalized_pos=(0.98, 0.6), size=(120, 0), label_format='%0.2lf')
    global size
    size = renderer.GetSize()

    def win_callback(obj, event):
        global size
        if (size != obj.GetSize()):
            button.place(renderer)
            button_plus.place(renderer)
            button_minus.place(renderer)
            slider.place(renderer)
            size = obj.GetSize()
    if interactive:
        show_manager.render()
        show_manager.start()
    if (not interactive):
        button.Off()
        slider.Off()
        arr = window.snapshot(renderer, size=(800, 800))
        report = window.analyze_snapshot(arr)
        npt.assert_equal(report.objects, 2)
    report = window.analyze_renderer(renderer)
    npt.assert_equal(report.actors, 1)
@xvfb_it
@npt.dec.skipif((not actor.have_vtk))
@npt.dec.skipif((not actor.have_vtk_colors))
def test_button_and_slider_widgets():
    interactive = False
    renderer = window.Renderer()
    lines = [np.array([[(- 1), 0, 0.0], [1, 0, 0.0]]), np.array([[(- 1), 1, 0.0], [1, 1, 0.0]])]
    colors = np.array([[1.0, 0.0, 0.0], [0.3, 0.7, 0.0]])
    stream_actor = actor.streamtube(lines, colors)
    renderer.add(stream_actor)
    show_manager = window.ShowManager(renderer, size=(800, 800))
    if interactive:
        show_manager.initialize()
        show_manager.render()

    def button_callback(obj, event):
        print('Camera pressed')

    def button_plus_callback(obj, event):
        print('+ pressed')

    def button_minus_callback(obj, event):
        print('- pressed')
    fetch_viz_icons()
    button_png = read_viz_icons(fname='camera.png')
    button = widget.button(show_manager.iren, show_manager.ren, button_callback, button_png, (0.98, 1.0), (80, 50))
    button_png_plus = read_viz_icons(fname='plus.png')
    button_plus = widget.button(show_manager.iren, show_manager.ren, button_plus_callback, button_png_plus, (0.98, 0.9), (120, 50))
    button_png_minus = read_viz_icons(fname='minus.png')
    button_minus = widget.button(show_manager.iren, show_manager.ren, button_minus_callback, button_png_minus, (0.98, 0.9), (50, 50))

    def print_status(obj, event):
        rep = obj.GetRepresentation()
        stream_actor.SetPosition((rep.GetValue(), 0, 0))
    slider = widget.slider(show_manager.iren, show_manager.ren, callback=print_status, min_value=(- 1), max_value=1, value=0.0, label='X', right_normalized_pos=(0.98, 0.6), size=(120, 0), label_format='%0.2lf')
    global size
    size = renderer.GetSize()

    def win_callback(obj, event):
        global size
        if (size != obj.GetSize()):
            button.place(renderer)
            button_plus.place(renderer)
            button_minus.place(renderer)
            slider.place(renderer)
            size = obj.GetSize()
    if interactive:
        show_manager.render()
        show_manager.start()
    if (not interactive):
        button.Off()
        slider.Off()
        arr = window.snapshot(renderer, size=(800, 800))
        report = window.analyze_snapshot(arr)
        npt.assert_equal(report.objects, 2)
    report = window.analyze_renderer(renderer)
    npt.assert_equal(report.actors, 1)