I was wondering if it is possible to send an image in my GUI but have the path saved as a fact in my database. Instead of calling it using
resource(logo,image,image('logo.jpg')).
Is it posible to call a variable inside ('logo.jpg')
that will change depending on the fact that is called?.
Asked
Active
Viewed 238 times
1

Jose Gonzalez
- 63
- 1
- 4
1 Answers
1
The better hint I can give you is to learn to use XPCE live documentation. From swipl-win open menu
\ Help \ XPCE (GUI) manual...
From there (the small window titled XPCE Manual
) open menu \ File \ Demo Programs
and from the list proposed click Image viewer
. Click button [ Source ]
and at bottom of file there is the code example you're looking for.
A bit of DRY could turn it in a reusable component. For instance:
/* File: pce_image_view.pl
Author: Carlo,,,
Created: May 19 2019
Purpose: answer https://stackoverflow.com/q/56201622/874024
*/
:- module(pce_image_view, [pce_image_view/1]).
:- use_module(library(pce)).
pce_image_view(Filename) :-
new(I, image(Filename)),
!,
new(B, bitmap(I)),
new(P, picture),
send(P, display, B),
send(P, open).
save the file, consult it and call:
?- pce_image_view('/home/carlo/Pictures/prova1.jpg').
true.
Sorry then demo program - it's a fairly complete local file typed browser - seems not working right now out-of-the-box. Anyway, some higher level constructs made available by recent language development could be applied to make the API more comfortable.

CapelliC
- 59,646
- 5
- 47
- 90