[Scilab-users] How to keep figure active with x_mdialog window open?

Rafael Guerra jrafaelbguerra at hotmail.com
Mon Jul 23 17:57:24 CEST 2018


Hi Izabela,

Following your post and Samuel’s feedback, I have tried the code below to do what you are after.
Script seems to work fine if run as standalone.
After hitting the pushbutton, the output vector “nn” contains the integers of multiple rows selected.

However, when I insert this code in a bigger program/loop, it does not work.

I have asked Samuel for help and he provided some additional tips which I did not try yet.

Let me know what is your experience.


// START OF CODE
stringmat = ["ITEM1";"ITEM2";"ITEM3";"ITEM4"];

// Callback function
function nn=save_exit(h_list)
    nn = get(h_list,"value");
    delete(get("SELECT MULTIPLE ITEMS"));
endfunction

w = 300; // width and height in pixels
h = 900;
max0 = max(size(stringmat));
stringmat = string((1:max0)') + repmat(" - ",max0,1) + stringmat;

// Create a figure
f = figure("figure_name", gettext("SELECT MULTIPLE ITEMS"),...
"infobar_visible", "off",...
"toolbar_visible", "off",...
"dockable", "off",...
"menubar", "none",...
"default_axes", "off", ...
"Position",[100 100 w h],...
"resize", "off",...
"BackgroundColor", [0.9 0.9 0.9],...
"Tag", "SELECT MULTIPLE ITEMS");

// display list
h_list = uicontrol(f, "Position", [15 45 w-20 h-50],.. // -20 to allow space for scroll bar
"Style", "listbox",...
"FontSize", 11,...
"String",  stringmat,...
"BackgroundColor", [1 1 1],...
"Max", max0,... //if Max>1 then allowed multiple selection
"Tag", "colors_listbox");

// Exit application
h = uicontrol(f, "Position", [15 15 160 25],...
"Style", "pushbutton",...
"String", gettext("SAVE & EXIT"),...
"FontSize", 11,...
"Callback", "nn=save_exit(h_list);");

// END OF CODE

Regards,
Rafael


More information about the users mailing list