I have a button in my script that opens a tkinter window to prompt the user to select a directory, for images to place into a report. I’ve been using tkinter to achieve this because I don’t want to upload many images (100+) as this would take a while, and I’m instead just using file paths. However, this won’t work when pushed onto the Viktor server. Do you have any suggestions on how to work around this or have a different method?
If i understand correctly: In your local script/dev environment(?) You select a folder, from which the local absolute path is saved. Next, you reference an image, which need to be placed in the report, by that selected path + filename. On rendering/creating the report, the image is placed in the report and the report is downloaded through the browser. Your problem is that when the app is deployed and running fully on the viktor platform, the app is cant acces the folder on your local machine and can’t generate the report.
Please, correct me if I am wrong.
A method you can use is creating an image library in your app. At the root level of you app, you can place an entity that functions as a folder. Under that entity, all images are uploaded once as a file entities (entities without parametrization, but with a file attached) The images is referenced in the report creation by pointing to the specific image file entity and fetching it’s file contents using the Viktor API.
Hope this helps,
Yep, you’re right about what I am trying to do. Just some questions on your solution.
- How would you save those upoaded files to a temp folder?
- So it is not possible to path to a directory on the users computer?
I’m quite curious about your use case! How are you creating these images? I am assuming that if you have this many images, and you want to place them all in a report in an automated way, that the images themselves are probably also generated automatically?
I think that we could find a nicer workaround for you if we know a bit more about why you need this many images, and how they are generated!
Our app is for engineers doing site visits and taking photos, mainly on there phones, of different aspects of a site, be it cracks, defects or point of interest. These photos are then placed into a report (either a word, powerpoint or PDF document), accompanied by a short description and image source. There can 100+ images in these reports.
The intended design for our Viktor app was to;
- Enter in a report name and image source (image source is consistent throughout report)
- Have the user select a folder directory that contains the images
- Select a report format, either DOCX or PPTX.
- Click a button that populates a table within the app, that has two columns, Image name and description. The user can then enter in a description for an image or copy and paste in a pre-written table from excel. We also have a dropdown menu containing the image names that the user can select and then update th eimage view (We would like the image view to update after selecting the image here)
- After filling in all the descriptions the user clicks a button and create the report.
- On the next step, the user can download the report. If they click update, a preview of the report is shown in a pdf format. (We would like this view to be triggered with the previous, ‘Create Report’ button)
- The download of the report is a zip file containing the report in a PDF format and the chosen format from step 3.
Here are some images of the current interface:
- Uploading 100+ images to viktor takes time and seems inefficient. We would like to just upload a folder path, and then when actually making the report we can go grab the images and place them in the report. Currently we have to upload them, convert to bytes, pass to a function that places them in a report. Moving this process into an action that only occurs after pressing a button helps with the efficiency of the app as there would only be one long load time as opposed to several.
- Views only updating when clicking update rather than triggering on a user interaction with a specific paramater. (We don’t want the view to trigger after every change to a paramater (because its slow), therefore changing the duration guess to below 3 isn’t an option. (This was raised in a seperate post and has been added to your feature requests I believe).
Hope this is clear.