【发布时间】:2012-12-21 09:30:17
【问题描述】:
?- new(B, button(hello,
message(@pce, write_ln, hello))).
在xpce/prolog中,这种方式创建一个按钮来打印一个句子 有什么方法可以让我点击一个按钮时我想做一些功能,请帮忙!
【问题讨论】:
标签: swi-prolog xpce
?- new(B, button(hello,
message(@pce, write_ln, hello))).
在xpce/prolog中,这种方式创建一个按钮来打印一个句子 有什么方法可以让我点击一个按钮时我想做一些功能,请帮忙!
【问题讨论】:
标签: swi-prolog xpce
从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 处于活动状态。
【讨论】: