English 中文(简体)
Prolog XPCE 对话框返回选择列表
原标题:Prolog XPCE dialog return a list of selections

我有另一个问题 与Prolog 在那里,我找不到一个线索 如何解决这个问题。

这是我的代码

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).

我需要两个周期的选择来启动另一个函数。 但是 prolog 不能打开包装操作 。

如果对话框让我返回 {[第一个选择,第二个选择], 问题就会得到解决 。

希望你能帮我 我对此非常失望...

问题回答

您应该阅读此页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).




相关问题
Prolog : Learning by example

I am trying to learn a little bit about swi-prolog (beyond the basic, useless programs). Can anyone explain (perhaps in pseudocode) what this sudoku solver and the related functions are doing? If ...

Working with lists in Prolog

First off let me state that this is part of a class exercise given as homework. But, the entire assignment is much more involved than the subject of this question. So.. I am searching through two ...

SWI-Prolog conditional statements

I m trying to write a function that will test to see if the word hello is contained in a list. If it is contained, i don t want it to say "true", i want it to say : "yes, the word hello is contained ...

prolog cut off in method

I have a question I would like to ask you something about a code snippet: insert_pq(State, [], [State]) :- !. insert_pq(State, [H|Tail], [State, H|Tail]) :- precedes(State, H). insert_pq(State, [...

Max out of values defined by prolog clauses

I know how to iterate over lists in Prolog to find the maximum, but what if each thing is a separate clause? For example if I had a bunch of felines and their ages, how would I find the oldest kitty? ...

热门标签