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

Izabela Wójcik-Grząba iwoj at il.pw.edu.pl
Tue Jul 24 14:41:29 CEST 2018


I think I've got something that works fine for me. I slightly changed 
and added something new to Rafael's code:

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

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
"Callback","list_values",..
"Tag", "example_listbox");

// Exit application
h0=uicontrol(f, "Position", [15 15 160 25],...
"Style", "pushbutton",...
"String", gettext("EXIT"),...
"FontSize", 11,...
"Callback", "closing");

// Callback functions
global a; a=[];
function list_values()
       global a
       a=[a;gcbo().value]
endfunction

function closing()
     ch=gcbo();
     close(ch.parent);
endfunction

// END OF CODE

In the vector "a" there are the numbers of items chosen from the list.

Iza



More information about the users mailing list