Prolog XPCE dialog return a list of selections

748 Views Asked by At

i have another Problem with Prolog where i cant find a clue how to solve it.

here is my code

list(Q):-
new(D,dialog('Sehenswuerdigkeiten')),
send_list(D,append,
[
new(Von,menu(von,cycle)),
new(Zu,menu(zu,cycle)),
new(@button,button('Los',message(@prolog,packing,Von?selection,Zu?selection,Q)))

]),
findall(X,sehenwuerdigkeit(X),Y),
send_list(Von, append,Y),
send_list(Zu, append,Y),
send(D,open).

packing(X,Y,Q):-Q=[X,Y]. 

:-consult('sw.pl'),list(Q).

I need both selections of the cycles to start another function. But prolog cant open the packing operation.

The problem is solved if the dialog gives me Q=[first selection,second selection] back.

Hope you can help me. Im very frustrated about this ...

1

There are 1 best solutions below

1
On

You should read this page http://www.swi-prolog.org/packages/xpce/UserGuide/modal.html

list(Q):-
    new(D,dialog('Sehenswuerdigkeiten')),
    send_list(D,append,
      [new(Von,menu(von,cycle)),
       new(Zu,menu(zu,cycle)),
       new(_,
           button('Los',
              message(D,return,[Von,Zu])))]),
    findall(X,city(X),Y),
    send_list(Von, append,Y),
    send_list(Zu, append,Y),
    get(D,confirm, Answer),
    get(Answer, element(1), A),
    get(A, selection, AV),
    get(Answer, element(2), B),
    get(B, selection, BV),
    send(D, destroy),
    Q = [AV, BV].

city(berlin).
city(london).
city(paris).
city(rom).