?- new(B, button(hello,
message(@pce, write_ln, hello))).
In xpce/prolog, this the way to create a button to print a sentence is there any way that when i click a button i want to do some function, please help!
from Help > XPCE manual > Browsers > Examples > Obtainers
+ Right Click + Select
you can see a practical example.
create_person_dialog :-
new(D, dialog('Enter new person')),
send(D, append, new(label)), % for reports
send(D, append, new(Name, text_item(name))),
send(D, append, new(Age, text_item(age))),
send(D, append, new(Sex, menu(sex, marked))),
send(Sex, append, female),
send(Sex, append, male),
send(Age, type, int),
send(D, append,
button(create, message(@prolog, create_person,
Name?selection,
Age?selection,
Sex?selection))),
send(D, default_button, create),
send(D, open).
create_person(Name, Age, Sex) :-
format('Creating ~w person ~w of ~d years old~n',
[Sex, Name, Age]).
After open highlight create_person_dialog
, right click and Consult
should get (I filled some value)
and clicking Create
output in console
Creating male person goofy of 99 years old
Generally you need to attach
your buttons to some GUI to get their functionality.
HTH
edit here the layout I get on Windows
there is a difference in the way those 2 images are obtained: in Windows I have the context menu Consult
active after opened the help topic.