ImageView per Step

I have a problem with loading different image views in different steps.

I’m creating an app with 2 steps. In each step, I want on the left the user inputs, and on the right some image (pdf or jpg) that “describes” the step.

I’ve created 2 ImageViews in the Controller:

class Controller(vkt.Controller):
    parametrization = Parametrization

    def __init__(self):
        self.image_dir = Path(__file__).parent / "images"

    @ImageView("Cartouche")   # for step 1
    def get_template_cartouche(self, params, **kwargs):
        image_path = self.image_dir / "Cartouche_Bottes.jpg"
        return ImageResult.from_path(image_path)

    @ImageView("Géométrie")  # for step 2
    def get_image_geometrie(self, params, **kwargs):
        image_path = self.image_dir / "Geometrie.jpg"
        return ImageResult.from_path(image_path)

which are called in the Parametrization class:

# Step 1
cartouche = Step("Cartouche", views="get_template_cartouche")
# do stuff

# Step 2
geom = Step("Données du Projet", views="get_image_geometrie")

However when starting the app, in the 2nd step the image loads forever and never actually appears.

It can’t be a problem with the ImageView definitions: if I remove step 1, step 2 loads properly. I also tried with different combinations of views arguments:

views="get_template_cartouche"  # image 1
views="get_image_geometrie"   # image 2
views=["get_template_cartouche", "get_image_geometrie"]  # images 1+2
Step 1
image(s)
Step 2
image(s)
Result
1 1 :white_check_mark:
2 2 :white_check_mark:
1+2 1 :white_check_mark:
1+2 2 :hourglass_not_done: Image 2 only loads in Step 2 if beforehand in Step 1 it was clicked on
1 2 :cross_mark:
2 1 :cross_mark:

Does anyone have an idea of why that is?
Thank you,
Remi

Hi @RemiPelletier ,

I’m trying to replicate your case, but unfortunately without success. This code of mine works fine with the scenario 5 (1 - 2), but I’ve also tried the 4th and last scenario with success:

from pathlib import Path

import viktor as vkt


class Parametrization(vkt.Parametrization):
    # Step 1
    cartouche = vkt.Step("Cartouche", views="get_template_cartouche")
    # do stuff

    # Step 2
    geom = vkt.Step("Données du Projet", views="get_image_geometrie")


class Controller(vkt.Controller):
    parametrization = Parametrization

    def __init__(self):
        self.image_dir = Path(__file__).parent / "images"

    @vkt.ImageView("Cartouche")   # for step 1
    def get_template_cartouche(self, params, **kwargs):
        image_path = self.image_dir / "aic-home.jpg"
        return vkt.ImageResult.from_path(image_path)

    @vkt.ImageView("Géométrie")  # for step 2
    def get_image_geometrie(self, params, **kwargs):
        image_path = self.image_dir / "jpeg-home.jpg"
        return vkt.ImageResult.from_path(image_path)

Could you share the following information with me?


Online: viktor.ai: v25.06.0

At viktor-cli start:

2025-06-04 15:21:22.299 INFO    : VIKTOR connector : v6.4.1
2025-06-04 15:21:22.299 INFO    : VIKTOR CLI       : v0.44.3
2025-06-04 15:21:22.299 INFO    : VIKTOR SDK       : v14.21.0

I should also probably specify that the app is not published yet.

Apologies for the bother, I have found that the bug came from a mistake in the on_next function I had set in the first step. I did not think it was relevant to the issue and stripped it from my bug description.
Sorry again! @mslootweg @rvandijk

1 Like

No worries! Happy that you were able to solve it.