# XPCE, interface with library(pce)

**URL:** <https://swi-prolog.discourse.group/t/xpce-interface-with-library-pce/7376>\
**Category:** General\
**Tags:** xpce\
**Created:** [April 14, 2024, 11:35pm UTC](https://swi-prolog.discourse.group/t/xpce-interface-with-library-pce/7376 "2024-04-14T23:35:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![esfort](https://avatars.discourse-cdn.com/v4/letter/e/e19b73/32.png) [@esfort](https://swi-prolog.discourse.group/u/esfort)\
**Post date:** [April 14, 2024, 11:35pm UTC](https://swi-prolog.discourse.group/t/xpce-interface-with-library-pce/7376/1 "2024-04-14T23:35:50Z")

</div>

Hello everyone. I’m making an interface for my expert system. Faced with the problem of multiple choice/tick-box/multiple selection. I’m trying and testing on a small example. Problem: after I select the options, I can’t continue working with them. Either errors or outputs as @274576025436. Ideally: add all the selected options to the list.  
Just select **Option 1** , **Option 2** , **Option 3** , **Option 4** , I select **Option 1** , **Option 3** , get the message [‘Option 1’, ‘Option 3’].

I also found this code on github:  
[link to github](https://github.getafreenode.com/SWI-Prolog/packages-xpce/blob/master/prolog/lib/pce_tick_box.pl)

If you can help me, I will be very grateful, because I have been struggling with this problem for a long time. Entering numbers of answer options from the keyboard does not look so attractive.

Here is my test code on which I am trying to implement this:

```prolog
:- use_module(library(pce)).

% Predicate to create a window with multi-selection
create_multi_select :-
    % Create a dialog window
    new(Dialog, dialog('Multi-Selection Example')),
    % Create a multi-selection
    new(Multiselect, menu),
    % Add options to the multi-selection
    send_list(Multiselect, append, ['Option 1', 'Option 2', 'Option 3', 'Option 4']),
    % Enable multiple selection
    send(Multiselect, multiple_selection, @on),
    % Add the multi-selection to the dialog window
    send(Dialog, append, Multiselect),
    % Add a button to display selected values
    send(Dialog, append, button('Submit', message(@prolog, show_selected, Multiselect))),
    % Open the dialog window
    send(Dialog, open).

% Predicate to display selected values
show_selected(Multiselect) :-
    write(Multiselect),
    % Get the selected values from the multi-selection
    get(Multiselect, selection, Selections),
    forall(member(Selection, Selections),
           (
    get(Multiselect, member, Selection, Option),
    % Answer=Options,
    % Display selected values
    writeln('Selected options:'),
    writeln(Option))).
```
