?- new(B, button(hello,
message(@pce, write_ln, hello))).
在xpce / prolog中,这是创建按钮来打印句子的方法 有什么办法,当我点击一个按钮,我想做一些功能,请帮忙!
答案 0 :(得分:3)
来自Help > XPCE manual > Browsers > Examples > Obtainers
+右键点击+ Select
您可以看到一个实际的例子。
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]).
在打开突出显示create_person_dialog
后,右键单击并Consult
应该得到(我填写了一些值)
并点击控制台中的Create
输出
Creating male person goofy of 99 years old
通常,您需要attach
按钮到某个GUI才能获得其功能。
HTH
编辑这是我在Windows上获得的布局
方式获得了这两个图像的区别:在Windows中,我打开帮助主题后启用了上下文菜单Consult
。