File: test_colorbar.py

package info (click to toggle)
python-vispy 0.16.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,112 kB
  • sloc: python: 61,648; javascript: 6,800; ansic: 2,104; makefile: 141; sh: 6
file content (47 lines) | stat: -rw-r--r-- 1,362 bytes parent folder | download | duplicates (2)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-

"""Tests for ColorbarVWidget.

All images are of size (100,100) to keep a small file size

"""

from vispy.scene.widgets import ColorBarWidget
from vispy.testing import (requires_application, TestingCanvas,
                           run_tests_if_main)
from vispy.testing.image_tester import assert_image_approved


def create_colorbar(pos, orientation, label='label string here'):
    colorbar = ColorBarWidget(pos=pos,
                              orientation=orientation,
                              label=label,
                              cmap='autumn',
                              border_color='white',
                              border_width=2)

    colorbar.label.color = 'white'
    colorbar.label.font_size = 5

    colorbar.ticks[0].color = 'white'
    colorbar.ticks[0].font_size = 5

    colorbar.ticks[1].color = 'white'
    colorbar.ticks[1].font_size = 5

    return colorbar


@requires_application()
def test_colorbar_widget():
    with TestingCanvas() as c:
        colorbar_top = create_colorbar(pos=(50, 50),
                                       label="my label",
                                       orientation='top')

        c.draw_visual(colorbar_top)
        assert_image_approved(c.render(), 'visuals/colorbar/top.png')
        assert colorbar_top.label.text == "my label"


run_tests_if_main()