简体   繁体   中英

How to connect a button to a function in xpce/prolog

This is a button:

new(B,button(solve, message(@prolog, solve))),
    send(D,display,B),
    send(D, open),

This is a function:

solve(D, Row, Column) :-
    assert(path([[0, 0], [-1, 0]])),
    track(Row, Column),
    path(P),
    show_track(D,P).

How should I do?

Here goes a sample to get you started:

:- use_module(library(pce)).

test:-
    new(D, dialog),
    new(W,  window('Test', size(100, 100))),
    send(D, append, new(B,button(solve, message(@prolog, solve, D, 10, 20)))),
    send(D, below, W),
    send(D, open),
    !.

solve(D, Row, Column) :-
  writeln(solve(D, Row, Column)).

Basically you have to add the arguments to the message, in this case I used D for the dialog and the constants 10 and 20 for Row and Column, and just print them to console in the solve/3 procedure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM