【问题标题】:how to create a button to do some function in xpce/prolog如何在 xpce/prolog 中创建一个按钮来执行某些功能
【发布时间】:2012-12-21 09:30:17
【问题描述】:
?- new(B, button(hello,
                 message(@pce, write_ln, hello))).

在xpce/prolog中,这种方式创建一个按钮来打印一个句子 有什么方法可以让我点击一个按钮时我想做一些功能,请帮忙!

【问题讨论】:

    标签: swi-prolog xpce


    【解决方案1】:

    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 处于活动状态。

    【讨论】:

    • 在 Windows 7 上我看不到这种对话框设计,你用什么操作系统?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-20
    • 2021-09-06
    • 2015-10-30
    • 1970-01-01
    • 1970-01-01
    • 2012-07-21
    相关资源
    最近更新 更多