Skip to main content
Version: 12.9.0

viktor.views

ViewError

exception viktor.views.ViewError

Bases: Exception

Exception applicable for incorrect usage of a view.

SummaryError

exception viktor.views.SummaryError

Bases: Exception

Exception applicable for incorrect usage of the summary.

DataStatus

class viktor.views.DataStatus(value)

Bases: enum.Enum

Enumeration of statuses to annotate a DataItem.

INFO: viktor.views.DataStatus = 'info'
SUCCESS: viktor.views.DataStatus = 'success'
WARNING: viktor.views.DataStatus = 'warning'
ERROR: viktor.views.DataStatus = 'error'

DataItem

class viktor.views.DataItem(label, value, subgroup=None, *, prefix='', suffix='', number_of_decimals=None, status=DataStatus.INFO, status_message='', explanation_label='')

Constructs an entry that can be used as input of a DataGroup, to fill the data viewer with results.

The data viewer is dynamic, which means that a DataItem itself can consist of another DataGroup as subgroup. Both examples are demonstrated below.

Example single entry:

result = "I am a great result"
item = DataItem('output 1', result)

Example subgroup:

result = "I am a great result"
item = DataItem('output 1', result, subgroup=DataGroup(
    output11=DataItem('output 1.1', "I can also be a numeric result"),
    output12=DataItem('output 1.2', 123)
))

The prefix / suffix can potentially change with every call. However, when the result is used in the Summary, the prefix / suffix of the DataItem should be equal to the prefix / suffix of the SummaryItem to maintain a consistent database.

Parameters
  • label (str) – Description of the value which is shown. e.g: ‘Uc bending’

  • value (Union[str, float, None]) – Value of the data. e.g: 0.9

  • subgroup (Optional[DataGroup]) – Optional DataItems grouped together in a DataGroup underneath this DataItem. Maximum depth = 3

  • prefix (str) – E.g: €. Should be equal to the prefix of the SummaryItem if linked.

  • suffix (str) – E.g: N. Should be equal to the suffix of the SummaryItem if linked.

  • number_of_decimals (Optional[int]) – Number of decimals with which the value is rounded for display.

  • status (DataStatus) –

    Status of value. This controls the formatting of the status_message:

    • status=DataStatus.INFO: black text

    • status=DataStatus.SUCCESS: green text

    • status=DataStatus.WARNING: orange text

    • status=DataStatus.ERROR: red text

  • status_message (str) – Message which will be shown underneath the value. Color can be formatted with status.

  • explanation_label (str) – Optional text which is placed between the label and the value. Could for instance be used for a calculation.

Raises

TypeError – if number_of_decimals is used on a non-numeric value.

property subgroup: viktor.views.DataGroup
Return type

DataGroup

DataGroup

class viktor.views.DataGroup(*args, **kwargs)

Bases: collections.OrderedDict

Container for DataItems, maximum number = 100. They can be added with or without a keyword argument, but they should be equal for all DataItems in the same DataGroup. Keywords are necessary when you want to use a DataItem in the summary (for lookup).

The following two use cases are valid:

d1 = DataGroup(
    DataItem('item1',0),
    DataItem('item2',1),
)

d2 = DataGroup(
    a=DataItem('item1',0),
    b=DataItem('item2',1),
)
Parameters
  • args (DataItem) – DataItem entries.

  • kwargs (DataItem) – Keyworded DataItem entries.

Raises
  • TypeError when positional- and keyword arguments are used together

  • AttributeError when more than 100 DataItems are used

classmethod from_data_groups(groups)

Constructs a combined DataGroup object from a list of individual DataGroup entries.

Note that is not possible to have multiple DataGroups that share a specific key for a DataItem, e.g. the following will result in an error:

d1 = DataGroup(output_a=DataItem(...))
d2 = DataGroup(output_a=DataItem(...))
d3 = DataGroup.from_data_groups([d1, d2])
Return type

DataGroup

Represents a link between a feature in a MapView and a specific entity.

Example usage:

gef_link = MapEntityLink('GEF x', gef_entity_id)
gef_marker = MapPoint(51.99311570849245, 4.385752379894256, entity_links=[gef_link])
Parameters
  • label (str) – The text which is shown to the user.

  • entity_id (int) – The identifier of the linked object.

MapFeature

class viktor.views.MapFeature(*, title=None, description=None, color=Color(39, 45, 51), entity_links=None)

Bases: abc.ABC

Warning

Do not use this class directly in an application.

Base class for features that can be shown in a MapView. See the documentation of the subclasses for example implementations.

Parameters
  • title (Optional[str]) – Title of a clickable map feature.

  • description (Optional[str]) – Description of a clickable map feature.

  • color (Color) – Specifies the color of the map feature.

  • entity_links (Optional[List[MapEntityLink]]) – When clicking on the map feature, links towards multiple entities can be shown.

MapPoint

class viktor.views.MapPoint(lat, lon, alt=0, **kwargs)

Bases: viktor.views.MapFeature

Represents a point on the Earth’s surface described by a latitude/longitude coordinate pair.

Example usage:

marker = MapPoint(51.99311570849245, 4.385752379894256)
Parameters
  • lat (float) – Latitude.

  • lon (float) – Longitude.

  • alt (float) – Altitude.

  • kwargs (Any) – See MapFeature for possible kwargs.

classmethod from_geo_point(point, **kwargs)

Instantiates a MapPoint from the provided GeoPoint.

Parameters
Return type

MapPoint

property lat: float
Return type

float

property lon: float
Return type

float

property alt: float
Return type

float

MapPolyline

class viktor.views.MapPolyline(*points, **kwargs)

Bases: viktor.views.MapFeature

Represents a polyline on the earth’s surface between several latitude/longitude pairs.

Example usage:

 line = MapPolyline(
    MapPoint(51.99311570849245, 4.385752379894256),
    MapPoint(52.40912125231122, 5.031738281255681),
    ...
)
Parameters
  • points (MapPoint) – MapPoints with latitude and longitude pair.

  • kwargs (Any) – See MapFeature for possible kwargs.

classmethod from_geo_polyline(polyline, **kwargs)

Instantiates a MapPolyline from the provided GeoPolyline.

Parameters
Return type

MapPolyline

property points: List[viktor.views.MapPoint]
Return type

List[MapPoint]

MapLine

class viktor.views.MapLine(start_point, end_point, **kwargs)

Bases: viktor.views.MapPolyline

Represents a line on the earth’s surface between two latitude/longitude pairs.

In case multiple line segments are to be created, a MapPolyline may be preferred.

Example usage:

 line = MapLine(
    MapPoint(51.99311570849245, 4.385752379894256),
    MapPoint(52.40912125231122, 5.031738281255681)
)
Parameters
  • start_point (MapPoint) – Map point with latitude and longitude pair.

  • end_point (MapPoint) – Map point with latitude and longitude pair.

  • kwargs (Any) – See MapFeature for possible kwargs.

property start_point: viktor.views.MapPoint
Return type

MapPoint

property end_point: viktor.views.MapPoint
Return type

MapPoint

MapPolygon

class viktor.views.MapPolygon(points, *, holes=None, **kwargs)

Bases: viktor.views.MapFeature

Represents a polygon on the earth’s surface formed by a set of latitude/longitude pairs.

Example usage:

polygon = MapPolygon([
    MapPoint(52.373922404495474, 5.2459716796875),
    MapPoint(52.10313118589299, 5.3997802734375),
    MapPoint(52.373922404495474, 5.57281494140625),
])
Parameters
  • points (List[MapPoint]) – Map points with latitude and longitude pair. The profile is automatically closed, so it is not necessary to add the start point at the end.

  • holes (Optional[List[MapPolygon]]) – List of interior polygons which form holes in the exterior polygon.

  • kwargs (Any) – See MapFeature for possible kwargs.

property points: List[viktor.views.MapPoint]
Return type

List[MapPoint]

property holes: List[viktor.views.MapPolygon]
Return type

List[MapPolygon]

classmethod from_geo_polygon(polygon, **kwargs)

Instantiates a MapPolygon from the provided GeoPolygon.

Parameters
Return type

MapPolygon

MapLegend

class viktor.views.MapLegend(entries)

A legend which is placed as an overlay on a map view.

Example usage:

legend = MapLegend([
    (Color.from_hex('#0016FF'), "I'm blue"),
    (Color.from_hex('#FF0000'), "I'm red"),
    ...
])
Parameters

entries (List[Tuple[Color, str]]) – Items in the legend, defined by color and label.

MapLabel

class viktor.views.MapLabel(lat, lon, text, scale)

Text which is placed as an overlay on the map.

Scale 0-5 is approximately the scale for countries:

/_images/map_label_scale_0_5.png

Scale 6-10 is approximately the scale for cities:

/_images/map_label_scale_6_11.png

Scale 11-15 is approximately the scale for neighborhoods and streets

/_images/map_label_scale_11_15.png

Scale 16-18 is approximately for individual houses.

/_images/map_label_scale_14_19.png
Parameters
  • lat (float) – Latitude of text in degrees.

  • lon (float) – Longitude of text in degrees.

  • text (str) – Text with is displayed on the map.

  • scale (float) – Size of the text on an exponential scale. See example in class docstring for estimate.

Label

class viktor.views.Label(point, *text, size_factor=1, color=Color(0, 0, 0))

Text label

Parameters
  • point (Point) – Position of the label.

  • text (str) – Text to show; multiple text arguments will each be shown on a new line.

  • size_factor (float) – Factor to be applied to the font size (0 < size_factor <= 10).

  • color (Color) – Color of the text.

property point: viktor.geometry.Point
Return type

Point

property text: Union[str, Tuple[str, ...]]
Return type

Union[str, Tuple[str, …]]

serialize()
Return type

dict

GeometryResult

class viktor.views.GeometryResult(visualization_group, labels=None)

Container with the results that should be visualized in a GeometryView. This consists of three-dimensional objects and optional text labels.

Parameters
  • visualization_group (Group) – Group that contains the geometric objects.

  • labels (Optional[List[Label]]) – Text labels that can be used to provide additional information.

GeometryAndDataResult

class viktor.views.GeometryAndDataResult(visualization_group, data, labels=None)

Container with the results that should be visualized in a GeometryAndDataView. This consists of three-dimensional objects with optional text labels and data.

Parameters
  • visualization_group (Group) – Group that contains the geometric objects.

  • data (DataGroup) – Result data.

  • labels (Optional[List[Label]]) – Text labels that can be used to provide additional information.

DataResult

class viktor.views.DataResult(data)

Container with the data results that should be shown in a DataView. This data can be nested up to three levels deep.

Parameters

data (DataGroup) – Result data.

PNGResult

class viktor.views.PNGResult(image)

Container with the PNG data that should be visualized in a PNGView.

Parameters

image (BytesIO) – BytesIO representation of the PNG content.

classmethod from_path(file_path)

Use file path to construct the image result.

Parameters

file_path (Union[str, bytes, PathLike]) – Path to the image.

Return type

PNGResult

PNGAndDataResult

class viktor.views.PNGAndDataResult(image, data)

Container with the PNG data that should be visualized in a PNGAndDataView, along with the result data.

Parameters
  • image (BytesIO) – BytesIO representation of the PNG content.

  • data (DataGroup) – Result data.

JPGResult

class viktor.views.JPGResult(image)

Container with the JPG data that should be visualized in a JPGView.

Parameters

image (BytesIO) – BytesIO representation of the JPG content.

classmethod from_path(file_path)

Use file path to construct the image result.

Parameters

file_path (Union[str, bytes, PathLike]) – Path to the image.

Return type

JPGResult

JPGAndDataResult

class viktor.views.JPGAndDataResult(image, data)

Container with the JPG data that should be visualized in a JPGAndDataView, along with the result data.

Parameters
  • image (BytesIO) – BytesIO representation of the JPG content.

  • data (DataGroup) – Result data.

SVGResult

class viktor.views.SVGResult(image)

Container with the SVG data that should be visualized in a SVGView.

Parameters

image (StringIO) – SVG image.

classmethod from_path(file_path)

Use file path to construct the image result.

Parameters

file_path (Union[str, bytes, PathLike]) – Path to the image.

Return type

SVGResult

SVGAndDataResult

class viktor.views.SVGAndDataResult(image, data)

Container with the SVG data that should be visualized in a SVGAndDataView, along with the result data.

Parameters
  • image (StringIO) – SVG image.

  • data (DataGroup) – Result data.

GeoJSONResult

class viktor.views.GeoJSONResult(geojson, labels=None, legend=None)

Container with the GeoJSON data that should be visualized in a GeoJSONView. Optionally a legend and map labels can be included.

The following geojson attributes are supported that can be used for styling of the map elements:

  • marker-color: the color of a marker *

  • description: text to show when this item is clicked

  • stroke: the color of a line as part of a polygon, polyline, or multigeometry *

  • fill: the color of the interior of a polygon *

*

color rules: Colors can be in short form “#ace” or long form “#aaccee”, and should contain the # prefix. Colors are interpreted the same as in CSS, in #RRGGBB and #RGB order.

Parameters
  • geojson (dict) – GeoJSON dictionary.

  • labels (Optional[List[MapLabel]]) – Labels that should be placed on the map.

  • legend (Optional[MapLegend]) – Map legend.

GeoJSONAndDataResult

class viktor.views.GeoJSONAndDataResult(geojson, data, labels=None, legend=None)

Container with the GeoJSON data and result data that should be visualized in a GeoJSONAndDataView. Optionally a legend and map labels can be included.

Parameters
  • geojson (dict) – GeoJSON dictionary.

  • data (DataGroup) – Result data.

  • labels (Optional[List[MapLabel]]) – Labels that should be placed on the map.

  • legend (Optional[MapLegend]) – Map legend.

MapResult

class viktor.views.MapResult(features, labels=None, legend=None)

Bases: viktor.views.GeoJSONResult

Container with the Map data that should be visualized in a MapView. Optionally a legend and map labels can be included.

Parameters
  • features (List[MapFeature]) – List that contains the map objects.

  • labels (Optional[List[MapLabel]]) – Labels that should be placed on the map.

  • legend (Optional[MapLegend]) – Map legend.

MapAndDataResult

class viktor.views.MapAndDataResult(features, data, labels=None, legend=None)

Bases: viktor.views.GeoJSONAndDataResult

Container with the Map data and result data that should be visualized in a MapAndDataView. Optionally a legend and map labels can be included.

Parameters
  • features (List[MapFeature]) – List that contains the map objects.

  • data (DataGroup) – Result data.

  • labels (Optional[List[MapLabel]]) – Labels that should be placed on the map.

  • legend (Optional[MapLegend]) – Map legend.

WebResult

class viktor.views.WebResult(*, html=None, url=None)

Container with the data that should be visualized in a WebView. There are two options, which should not be used together:

  • url: to serve a URL (takes precedence if both are defined)

  • html: for serving a single html page

Parameters
  • html (Optional[StringIO]) – HTML formatted content.

  • url (Optional[str]) – Direct URL.

classmethod from_path(file_path)
Return type

WebResult

WebAndDataResult

class viktor.views.WebAndDataResult(*, html=None, url=None, data=None)

Container with the web data and result data that should be visualized in a WebAndDataView.

The Web part can be constructed in two ways, which should not be used together:

  • url: to serve a URL (takes precedence if both are defined)

  • html: for serving a single html page

Parameters
  • html (Optional[StringIO]) – HTML formatted content.

  • url (Optional[str]) – Direct URL.

  • data (Optional[DataGroup]) – Result data.

PDFResult

class viktor.views.PDFResult(*, file=None, url=None)

PDF document to be visualized in a PDFView. Can be defined from a File object or from a URL (direct-sharing). If both file and url are defined, url takes precedence.

In case of URL: the hosting website must allow for direct accessing for the document to be shown. If this is forbidden (undefined CORS-headers), the document can alternatively be shown via the file argument with a File.from_url(…), in which it is downloaded first and viewed subsequently (indirect-sharing).

Example usages:

From URL (direct-sharing):

PDFResult(url="https://www...")

From URL (indirect-sharing):

f = File.from_url("https://www...")
PDFResult(file=f)

From path:

file_path = Path(__file__).parent / 'sample.pdf'
PDFResult.from_path(file_path)
Parameters
  • file (Optional[File]) – PDF document to view

  • url (Optional[str]) – URL of PDF document to view. If accessing the PDF directly from the URL is not allowed by the host website (undefined CORS-headers), this will result in the document not showing up in the view (as an alternative one can use File.from_url).

classmethod from_path(file_path)

Create the PDFResult from a path to the PDF file.

Parameters

file_path (Union[str, bytes, PathLike]) – file path to a PDF file

Return type

PDFResult

SummaryItem

class viktor.views.SummaryItem(label, item_type, source, value_path, *, suffix='', prefix='')

A summary consists of SummaryItem objects, that define which input / result values should be displayed.

Suppose we have a data view with a controller method ‘data_view’, which returns a DataItem with key ‘output_item_1’. The following summary item can be constructed to refer to this result:

item_1 = SummaryItem('Label', float, 'data_view', 'output_item_1', suffix='N')

Suppose we have a parametrization with a certain parameter defined as geometry.input.length, this can be converted to a summary item by doing:

item_2 = SummaryItem('Length', float, 'parametrization', 'geometry.input.length', suffix='m')
Parameters
  • label (str) – Text label of the item.

  • item_type (Type[Union[str, float]]) – Type of value, options are ‘str’ | ‘float’.

  • source (str) – Source from which the input / output should be extracted.

  • value_path (str) – Dotted path of value in parametrization / data structure of view. e.g: level1.level2.value

  • suffix (str) – A prefix will be put behind the value to provide additional information such as units.

  • prefix (str) – A prefix will be put in front of the value to provide info such as a dollar sign.

Summary

class viktor.views.Summary(**items)

Bases: collections.OrderedDict

Summary of resulting data items, which can be used in the summary view of an entity.

Example usage:

class Controller:
    ...
    summary = Summary(
        item_1=SummaryItem(...),
        item_2=SummaryItem(...),
        item_3=SummaryItem(...)
    )
Parameters

items (SummaryItem) – Items that are shown in the summary, with a maximum of 6 items per summary.

View

class viktor.views.View(label, duration_guess, *, description=None, update_label=None, **kwargs)

Bases: abc.ABC

Warning

Do not use this class directly in an application.

Base-class of a function decorator that can be used to specify the desired view to be returned. See the subclasses for specific examples of each type of view.

Parameters
  • label (str) – Name which is shown on tab in interface. e.g: ‘3D Representation’

  • duration_guess (int) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.

  • description (Optional[str]) – Show more information to the user through a tooltip on hover (max. 200 characters).

  • update_label (Optional[str]) – Name which is shown on the update button in case of a slow view (max. 30 characters).

abstract property result_type: Type[viktor.views._ViewResult]
Return type

Type[_ViewResult]

GeometryView

class viktor.views.GeometryView(label, duration_guess, *, description=None, update_label=None, view_mode='3D', default_shadow=False)

Bases: viktor.views.View

Function decorator to instruct the controller method to return a geometry viewer (2D / 3D).

Example usage:

@GeometryView("3D model", duration_guess=2)
def get_geometry_view(self, params, **kwargs):
    # create 3d model
    ...
    return GeometryResult(geometry, labels)

@GeometryView("2D model", duration_guess=2, view_mode='2D')
def get_geometry_view_2d(self, params, **kwargs):
    # create 2d model
    ...
    return GeometryResult(geometry, labels)
Parameters
  • label (str) – See View.

  • duration_guess (int) – See View.

  • description (Optional[str]) – See View.

  • update_label (Optional[str]) – See View.

  • view_mode (str) –

    Sets the viewer mode:

    • ’3D’: Camera is free to move and user can choose between orthographic and perspective view.

    • ’2D’: Camera is fixed on the xy-plane and view is orthographic.

  • default_shadow (bool) – Show shadow when editor is opened. User can still switch it off.

result_type

alias of viktor.views.GeometryResult

DataView

class viktor.views.DataView(label, duration_guess, *, description=None, update_label=None, **kwargs)

Bases: viktor.views.View

Function decorator to instruct the controller method to return a data viewer that contains calculation result.

Example usage:

@DataView("Cost breakdown", duration_guess=2)
def get_data_view(self, params, **kwargs):
    # calculate data
    ...
    return DataResult(data_group)
Parameters
  • label (str) – Name which is shown on tab in interface. e.g: ‘3D Representation’

  • duration_guess (int) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.

  • description (Optional[str]) – Show more information to the user through a tooltip on hover (max. 200 characters).

  • update_label (Optional[str]) – Name which is shown on the update button in case of a slow view (max. 30 characters).

result_type

alias of viktor.views.DataResult

GeometryAndDataView

class viktor.views.GeometryAndDataView(label, duration_guess, *, description=None, update_label=None, view_mode='3D', default_shadow=False)

Bases: viktor.views.View

Function decorator to instruct the controller method to return a combined viewer consisting of geometries and data.

Example usage:

@GeometryAndDataView("Model / Cost", duration_guess=2)
def get_geometry_data_view(self, params, **kwargs):
    # create 3d model
    ...
    # calculate data
    ...
    return GeometryAndDataResult(geometry, data_group, labels=labels)
Parameters
  • label (str) – See View.

  • duration_guess (int) – See View.

  • description (Optional[str]) – See View.

  • update_label (Optional[str]) – See View.

  • view_mode (str) –

    Sets the viewer mode:

    • ’3D’: Camera is free to move and user can choose between orthographic and perspective view.

    • ’2D’: Camera is fixed on the xy-plane and view is orthographic.

  • default_shadow (bool) – Show shadow when editor is opened. User can still switch it off.

result_type

alias of viktor.views.GeometryAndDataResult

SVGView

class viktor.views.SVGView(label, duration_guess, *, description=None, update_label=None, **kwargs)

Bases: viktor.views.View

Function decorator to instruct the controller method to return an SVG viewer.

Example usage:

@SVGView("SVG plot", duration_guess=2)
def get_svg_view(self, params, **kwargs):
    # create svg image
    ...
    return SVGResult(svg_image)
Parameters
  • label (str) – Name which is shown on tab in interface. e.g: ‘3D Representation’

  • duration_guess (int) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.

  • description (Optional[str]) – Show more information to the user through a tooltip on hover (max. 200 characters).

  • update_label (Optional[str]) – Name which is shown on the update button in case of a slow view (max. 30 characters).

result_type

alias of viktor.views.SVGResult

SVGAndDataView

class viktor.views.SVGAndDataView(label, duration_guess, *, description=None, update_label=None, **kwargs)

Bases: viktor.views.View

Function decorator to instruct the controller method to return a combined viewer consisting of an SVG and data.

Example usage:

@SVGAndDataView("Plot / Cost", duration_guess=2)
def get_svg_data_view(self, params, **kwargs):
    # create svg image
    ...
    # calculate data
    ...
    return SVGAndDataResult(svg_image, data_group)
Parameters
  • label (str) – Name which is shown on tab in interface. e.g: ‘3D Representation’

  • duration_guess (int) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.

  • description (Optional[str]) – Show more information to the user through a tooltip on hover (max. 200 characters).

  • update_label (Optional[str]) – Name which is shown on the update button in case of a slow view (max. 30 characters).

result_type

alias of viktor.views.SVGAndDataResult

GeoJSONView

class viktor.views.GeoJSONView(label, duration_guess, *, description=None, update_label=None, **kwargs)

Bases: viktor.views.View

Function decorator to instruct the controller method to return a GeoJSON (geographic data) viewer.

Example usage:

@GeoJSONView("Map", duration_guess=2)
def get_geojson_view(self, params, **kwargs):
    # create geojson data
    ...
    return GeoJSONResult(geojson, labels, legend)
Parameters
  • label (str) – Name which is shown on tab in interface. e.g: ‘3D Representation’

  • duration_guess (int) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.

  • description (Optional[str]) – Show more information to the user through a tooltip on hover (max. 200 characters).

  • update_label (Optional[str]) – Name which is shown on the update button in case of a slow view (max. 30 characters).

result_type

alias of viktor.views.GeoJSONResult

GeoJSONAndDataView

class viktor.views.GeoJSONAndDataView(label, duration_guess, *, description=None, update_label=None, **kwargs)

Bases: viktor.views.View

Function decorator to instruct the controller method to return a combined viewer consisting of a GeoJSON and data.

Example usage:

@SVGAndDataView("Map / Data", duration_guess=2)
def get_geojson_data_view(self, params, **kwargs):
    # create geojson data
    ...
    # calculate data
    ...
    return GeoJSONAndDataResult(geojson, data_group, labels, legend)
Parameters
  • label (str) – Name which is shown on tab in interface. e.g: ‘3D Representation’

  • duration_guess (int) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.

  • description (Optional[str]) – Show more information to the user through a tooltip on hover (max. 200 characters).

  • update_label (Optional[str]) – Name which is shown on the update button in case of a slow view (max. 30 characters).

result_type

alias of viktor.views.GeoJSONAndDataResult

MapView

class viktor.views.MapView(label, duration_guess, *, description=None, update_label=None, **kwargs)

Bases: viktor.views.View

Function decorator to instruct the controller method to return a Map (geographic data) viewer.

Example usage:

@MapView("Map", duration_guess=2)
def get_map_view(self, params, **kwargs):
    # create map geometry objects
    ...
    return MapResult(features, labels, legend)
Parameters
  • label (str) – Name which is shown on tab in interface. e.g: ‘3D Representation’

  • duration_guess (int) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.

  • description (Optional[str]) – Show more information to the user through a tooltip on hover (max. 200 characters).

  • update_label (Optional[str]) – Name which is shown on the update button in case of a slow view (max. 30 characters).

result_type

alias of viktor.views.MapResult

MapAndDataView

class viktor.views.MapAndDataView(label, duration_guess, *, description=None, update_label=None, **kwargs)

Bases: viktor.views.View

Function decorator to instruct the controller method to return a combined viewer consisting of a Map and data.

Example usage:

@MapAndDataView("Map / Data", duration_guess=2)
def get_map_data_view(self, params, **kwargs):
    # create map data
    ...
    # calculate data
    ...
    return MapAndDataResult(features, data_group, labels, legend)
Parameters
  • label (str) – Name which is shown on tab in interface. e.g: ‘3D Representation’

  • duration_guess (int) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.

  • description (Optional[str]) – Show more information to the user through a tooltip on hover (max. 200 characters).

  • update_label (Optional[str]) – Name which is shown on the update button in case of a slow view (max. 30 characters).

result_type

alias of viktor.views.MapAndDataResult

PNGView

class viktor.views.PNGView(label, duration_guess, *, description=None, update_label=None, **kwargs)

Bases: viktor.views.View

Function decorator to instruct the controller method to return a PNG viewer.

Example usage:

@PNGView("PNG image", duration_guess=1)
def get_png_view(self, params, **kwargs):
    # get png image
    ...
    return PNGResult(image)
Parameters
  • label (str) – Name which is shown on tab in interface. e.g: ‘3D Representation’

  • duration_guess (int) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.

  • description (Optional[str]) – Show more information to the user through a tooltip on hover (max. 200 characters).

  • update_label (Optional[str]) – Name which is shown on the update button in case of a slow view (max. 30 characters).

result_type

alias of viktor.views.PNGResult

PNGAndDataView

class viktor.views.PNGAndDataView(label, duration_guess, *, description=None, update_label=None, **kwargs)

Bases: viktor.views.View

Function decorator to instruct the controller method to return a combined viewer consisting of a PNG and data.

Example usage:

@PNGAndDataView("PNG / Data", duration_guess=1)
def get_png_data_view(self, params, **kwargs):
    # get png image
    ...
    # calculate data
    ...
    return PNGAndDataResult(image, data_group)
Parameters
  • label (str) – Name which is shown on tab in interface. e.g: ‘3D Representation’

  • duration_guess (int) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.

  • description (Optional[str]) – Show more information to the user through a tooltip on hover (max. 200 characters).

  • update_label (Optional[str]) – Name which is shown on the update button in case of a slow view (max. 30 characters).

result_type

alias of viktor.views.PNGAndDataResult

JPGView

class viktor.views.JPGView(label, duration_guess, *, description=None, update_label=None, **kwargs)

Bases: viktor.views.View

Function decorator to instruct the controller method to return a JPG viewer.

Example usage:

@JPGView("JPG image", duration_guess=1)
def get_jpg_view(self, params, **kwargs):
    # get jpg image
    ...
    return JPGResult(image)
Parameters
  • label (str) – Name which is shown on tab in interface. e.g: ‘3D Representation’

  • duration_guess (int) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.

  • description (Optional[str]) – Show more information to the user through a tooltip on hover (max. 200 characters).

  • update_label (Optional[str]) – Name which is shown on the update button in case of a slow view (max. 30 characters).

result_type

alias of viktor.views.JPGResult

JPGAndDataView

class viktor.views.JPGAndDataView(label, duration_guess, *, description=None, update_label=None, **kwargs)

Bases: viktor.views.View

Function decorator to instruct the controller method to return a combined viewer consisting of a JPG and data.

Example usage:

@JPGAndDataView("JPG / Data", duration_guess=1)
def get_jpg_data_view(self, params, **kwargs):
    # get jpg image
    ...
    # calculate data
    ...
    return JPGAndDataResult(image, data_group)
Parameters
  • label (str) – Name which is shown on tab in interface. e.g: ‘3D Representation’

  • duration_guess (int) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.

  • description (Optional[str]) – Show more information to the user through a tooltip on hover (max. 200 characters).

  • update_label (Optional[str]) – Name which is shown on the update button in case of a slow view (max. 30 characters).

result_type

alias of viktor.views.JPGAndDataResult

WebView

class viktor.views.WebView(label, duration_guess, *, description=None, update_label=None, **kwargs)

Bases: viktor.views.View

Function decorator to instruct the controller method to return a web-content viewer.

Example usage:

@WebView("Hello world", duration_guess=1)
def get_web_view(self, params, **kwargs):
    html = StringIO("<html>Hello world</html>")
    return WebResult(html=html)
Parameters
  • label (str) – Name which is shown on tab in interface. e.g: ‘3D Representation’

  • duration_guess (int) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.

  • description (Optional[str]) – Show more information to the user through a tooltip on hover (max. 200 characters).

  • update_label (Optional[str]) – Name which is shown on the update button in case of a slow view (max. 30 characters).

result_type

alias of viktor.views.WebResult

WebAndDataView

class viktor.views.WebAndDataView(label, duration_guess, *, description=None, update_label=None, **kwargs)

Bases: viktor.views.View

Function decorator to instruct the controller method to return a combined viewer consisting of web-content and data.

Example usage:

@WebAndDataView("Web / Data", duration_guess=1)
def get_web_data_view(self, params, **kwargs):
    # get html
    html = StringIO("<html>Hello world</html>")

    # calculate data
    ...
    return WebAndDataResult(html=html, data=data_group)
Parameters
  • label (str) – Name which is shown on tab in interface. e.g: ‘3D Representation’

  • duration_guess (int) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.

  • description (Optional[str]) – Show more information to the user through a tooltip on hover (max. 200 characters).

  • update_label (Optional[str]) – Name which is shown on the update button in case of a slow view (max. 30 characters).

result_type

alias of viktor.views.WebAndDataResult

PDFView

class viktor.views.PDFView(label, duration_guess, *, description=None, update_label=None, **kwargs)

Bases: viktor.views.View

Function decorator to instruct the controller method to return a PDFView.

Example usage:

@PDFView("PDF Viewer", duration_guess=1)
def get_pdf_view(self, params, **kwargs):
    file_path = Path(__file__).parent / 'sample.pdf'
    return PDFResult.from_path(file_path)
Parameters
  • label (str) – Name which is shown on tab in interface. e.g: ‘3D Representation’

  • duration_guess (int) – Estimation of view calculation in seconds. This will be used to add a manual refresh button for long running tasks (larger than 3s). This estimation does not need to be very precise, but the performance will be better if this is close to the real maximum computation time.

  • description (Optional[str]) – Show more information to the user through a tooltip on hover (max. 200 characters).

  • update_label (Optional[str]) – Name which is shown on the update button in case of a slow view (max. 30 characters).

result_type

alias of viktor.views.PDFResult