首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在xpce/prolog中创建一个按钮来执行某些功能

如何在xpce/prolog中创建一个按钮来执行某些功能
EN

Stack Overflow用户
提问于 2012-12-21 09:30:17
回答 1查看 3.2K关注 0票数 1
代码语言:javascript
复制
?- new(B, button(hello,
                 message(@pce, write_ln, hello))).

在xpce/prolog中,创建一个按钮来打印句子的方法是,当我单击一个按钮时,我想要做一些功能,请帮助!

EN

回答 1

Stack Overflow用户

发布于 2012-12-21 10:07:35

Help > XPCE manual > Browsers > Examples > Obtainers +右单击+ Select中,您可以看到一个实用的示例。

代码语言:javascript
复制
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输出。

代码语言:javascript
复制
Creating male person goofy of 99 years old

通常,您需要将按钮attach到某些GUI以获得它们的功能。

HTH

编辑这里是我在Windows上获得的布局

获得这2幅图像的方式有所不同:在Windows中,在打开帮助主题后,上下文菜单Consult处于活动状态。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13987487

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档