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

classic Classic list List threaded Threaded
12 messages Options
Iza Iza
Reply | Threaded
Open this post in threaded view
|

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

Hi all,

I have another problem. In my program I create an initial plot which is
a basis for the input implemented by x_mdialog command. The problem is
that when the x_mdialog window pops up the figure window bocomes
inactive. It means that I can't zoom or rotate the plot which is
necessary to correctly enter the data to x_mdialog matrix. Is there any
solution to this? Is it possible to keep the figure active when other
windows occur?

Thanks in advance,
Iza
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: How to keep figure active with x_mdialog window open?

Hello Izabela,

What you wish to do is not possible with x_mdialog(), that is a modal
dialog: it pauses everything else until the dialog is quit.

To do what you want, it's possible to create your own dialog box based
on uicontrol("style", "edit") or other interactive components.
Basically, you may have a look at the demos demo_gui(): GUI =>
Uicontrosl1 or Uicontrols2. Both have a "View-code" link in their menu bar.

Best regards
Samuel

Le 19/07/2018 à 14:13, Izabela Wójcik-Grząba a écrit :

> Hi all,
>
> I have another problem. In my program I create an initial plot which
> is a basis for the input implemented by x_mdialog command. The problem
> is that when the x_mdialog window pops up the figure window bocomes
> inactive. It means that I can't zoom or rotate the plot which is
> necessary to correctly enter the data to x_mdialog matrix. Is there
> any solution to this? Is it possible to keep the figure active when
> other windows occur?
>
> Thanks in advance,
> Iza
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
>

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Iza Iza
Reply | Threaded
Open this post in threaded view
|

Re: How to keep figure active with x_mdialog window open?

Thank you for the explanation and suggestions. I will have to put my
x_mdialog into another graphic window.

Iza




W dniu 19.07.2018 20:43, Samuel Gougeon napisał(a):

> Hello Izabela,
>
> What you wish to do is not possible with x_mdialog(), that is a modal
> dialog: it pauses everything else until the dialog is quit.
>
> To do what you want, it's possible to create your own dialog box based
> on uicontrol("style", "edit") or other interactive components.
> Basically, you may have a look at the demos demo_gui(): GUI =>
> Uicontrosl1 or Uicontrols2. Both have a "View-code" link in their menu
> bar.
>
> Best regards
> Samuel
>
> Le 19/07/2018 à 14:13, Izabela Wójcik-Grząba a écrit :
>> Hi all,
>>
>> I have another problem. In my program I create an initial plot which
>> is a basis for the input implemented by x_mdialog command. The problem
>> is that when the x_mdialog window pops up the figure window bocomes
>> inactive. It means that I can't zoom or rotate the plot which is
>> necessary to correctly enter the data to x_mdialog matrix. Is there
>> any solution to this? Is it possible to keep the figure active when
>> other windows occur?
>>
>> Thanks in advance,
>> Iza
>> _______________________________________________
>> users mailing list
>> [hidden email]
>> http://lists.scilab.org/mailman/listinfo/users
>>
>
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Iza Iza
Reply | Threaded
Open this post in threaded view
|

Re: How to keep figure active with x_mdialog window open?

I am trying to substitute my x_mdialog() by 3 listboxes put in a graphic
window. My code is a slightly remodelled version of a Demo "Listboxes
and popupmenus":

f = figure("dockable", "off" ,"infobar_visible", "off",
"toolbar_visible", "off", "menubar_visible", "off", "default_axes",
"off", "visible", "off", "layout", "gridbag");
set(f, "figure_id", 1);
set(f, "figure_name", "Listboxes and Popupmenus");
set(f, "axes_size", [850 120]);
kier_x = [
"W 1 x", "#000000", "#FFFFFF";
"W 2 x", "#FFFFFF", "#000000";
"W 3 x", "#000000", "#FFFFFF";
"W 4 x", "#FFFFFF", "#000000";
"W 5 x", "#000000", "#FFFFFF";
"W 6 x", "#FFFFFF", "#000000"];
c = createConstraints("gridbag", [1, 1, 1, 1], [1 1], "both");
list1=uicontrol(f, "style", "listbox", "constraints", c, "margins", [5 5
5 5],..
"max",20,"min",0, "string", kier_x);
kier_y = [
"W 1 y", "#000000", "#FFFFFF";
"W 2 y", "#FFFFFF", "#000000";
"W 3 y", "#000000", "#FFFFFF";
"W 4 y", "#FFFFFF", "#000000";
"W 5 y", "#000000", "#FFFFFF";
"W 6 y", "#FFFFFF", "#000000"];
c = createConstraints("gridbag", [2, 1, 1, 1], [1 1], "both");
list2=uicontrol(f, "style", "listbox", "constraints", c, "margins", [5 5
5 5],..
"max",20,"min",0, "string", kier_y);
kier_z = [
"W 1 z", "#000000", "#FFFFFF";
"W 2 z", "#FFFFFF", "#000000";
"W 3 z", "#000000", "#FFFFFF";
"W 4 z", "#FFFFFF", "#000000";
"W 5 z", "#000000", "#FFFFFF";
"W 6 z", "#FFFFFF", "#000000"];
c = createConstraints("gridbag", [3, 1, 1, 1], [1 1], "both");
list3=uicontrol(f, "style", "listbox", "constraints", c, "margins", [5 5
5 5],..
"max",20,"min",0, "string", kier_z);
set(f, "visible", "on");

I have two questions:
1. How to make the lists to be multiselect (now it seems that this
option doesn't work despite the max and min values)?
2. How to write the selected values into the vectors and then close the
window?

I know that these are simple questions but I am rather a beginner in
Scilab and I get more and more confused with every new problem.

Regards,
Iza





W dniu 20.07.2018 12:47, Izabela Wójcik-Grząba napisał(a):

> Thank you for the explanation and suggestions. I will have to put my
> x_mdialog into another graphic window.
>
> Iza
>
>
>
>
> W dniu 19.07.2018 20:43, Samuel Gougeon napisał(a):
>> Hello Izabela,
>>
>> What you wish to do is not possible with x_mdialog(), that is a modal
>> dialog: it pauses everything else until the dialog is quit.
>>
>> To do what you want, it's possible to create your own dialog box based
>> on uicontrol("style", "edit") or other interactive components.
>> Basically, you may have a look at the demos demo_gui(): GUI =>
>> Uicontrosl1 or Uicontrols2. Both have a "View-code" link in their menu
>> bar.
>>
>> Best regards
>> Samuel
>>
>> Le 19/07/2018 à 14:13, Izabela Wójcik-Grząba a écrit :
>>> Hi all,
>>>
>>> I have another problem. In my program I create an initial plot which
>>> is a basis for the input implemented by x_mdialog command. The
>>> problem is that when the x_mdialog window pops up the figure window
>>> bocomes inactive. It means that I can't zoom or rotate the plot which
>>> is necessary to correctly enter the data to x_mdialog matrix. Is
>>> there any solution to this? Is it possible to keep the figure active
>>> when other windows occur?
>>>
>>> Thanks in advance,
>>> Iza
>>> _______________________________________________
>>> users mailing list
>>> [hidden email]
>>> http://lists.scilab.org/mailman/listinfo/users
>>>
>>
>> _______________________________________________
>> users mailing list
>> [hidden email]
>> http://lists.scilab.org/mailman/listinfo/users
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: How to keep figure active with x_mdialog window open?

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
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: How to keep figure active with x_mdialog window open?

Hi Izabela and Samuel,

I have followed Samuel's awesome offline advice to try using the gcbo() function to retrieve the lost callback handle. The improved code below now seems to work like a charm, regardless of where I place it within a larger Scilab program/loop.

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

function nn=save_exit()
    nn = gcbo().Userdata.hlist.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
h0=uicontrol(f, "Position", [15 15 160 25],...
"Style", "pushbutton",...
"String", gettext("SAVE & EXIT"),...
"FontSize", 11,...
"Callback", "h0.Userdata.hlist=h_list; nn=save_exit();");
// END OF CODE

Thanks a lot Samuel, this is a really useful functionality.

Kind regards,
Rafael

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: How to keep figure active with x_mdialog window open?

My apologies, after further testing the last callback code does still not seem to be satisfactory.
Banging the head on this Scilab topic...


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: How to keep figure active with x_mdialog window open?

In reply to this post by Rafael Guerra
After studying some past threads by Serge Steer on this callback topic, the following approach seems more appropriate.
One may discard the too-simple function save_exit() in code snippet at the bottom and rewrite the section:

        // Exit application
        h0=uicontrol(f0, "Position", [15 15 160 25],...
        "Style", "pushbutton",...
        "String", gettext("SAVE & EXIT"),...
        "FontSize", 11,...
        "Callback", "gcbo.userdata.hlist= h_list;");

Within my major Scilab script loop, I have put this command:
        input("Select items and then ENTER to continue","string");
        nh0 = h0.userdata.hlist.value;

Which again works fine for standalone and in major loop issues error:
"Attempt to reference field of non-structure array."

However both typeof(h0.userdata.hlist.value) and typeof(nh0) are constant ...
And I see some hope in this as now, h0.userdata.hlist.value has the correct array of integer values

Any clues please?

Regards,
Rafael

-----Original Message-----
From: users <[hidden email]> On Behalf Of Rafael Guerra
Sent: Monday, July 23, 2018 10:42 PM
To: Users mailing list for Scilab <[hidden email]>
Subject: Re: [Scilab-users] How to keep figure active with x_mdialog window open?

Hi Izabela and Samuel,

I have followed Samuel's awesome offline advice to try using the gcbo() function to retrieve the lost callback handle. The improved code below now seems to work like a charm, regardless of where I place it within a larger Scilab program/loop.

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

function nn=save_exit()
    nn = gcbo().Userdata.hlist.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
h0=uicontrol(f, "Position", [15 15 160 25],...
"Style", "pushbutton",...
"String", gettext("SAVE & EXIT"),...
"FontSize", 11,...
"Callback", "h0.Userdata.hlist=h_list; nn=save_exit();");
// END OF CODE

Thanks a lot Samuel, this is a really useful functionality.

Kind regards,
Rafael

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Iza Iza
Reply | Threaded
Open this post in threaded view
|

Re: How to keep figure active with x_mdialog window open?

Rafael,

Thank you for your attempts. I thought it would be a rather simple task
because in the help text "value" for "listbox" uicontrol is described
as:
"value is a vector of indexes corresponding to the indexes of the
selected entries in the list. 1 is the first item of the list."
But when I type: h_list.value in the console I get only the last index
of my selection from the list.

Iza
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: How to keep figure active with x_mdialog window open?

Iza,

We are close to the solution but not there yet.
My head is now flattened of so much banging it against the desk, like the Columbus' egg...
Hopefully some experts may return from vacation and post the solution.

Regards,
Rafael

-----Original Message-----
From: users <[hidden email]> On Behalf Of Izabela Wójcik-Grzaba
Sent: Tuesday, July 24, 2018 1:40 PM
To: Users mailing list for Scilab <[hidden email]>
Subject: Re: [Scilab-users] How to keep figure active with x_mdialog window open?

Rafael,

Thank you for your attempts. I thought it would be a rather simple task because in the help text "value" for "listbox" uicontrol is described
as:
"value is a vector of indexes corresponding to the indexes of the selected entries in the list. 1 is the first item of the list."
But when I type: h_list.value in the console I get only the last index of my selection from the list.

Iza
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Iza Iza
Reply | Threaded
Open this post in threaded view
|

Re: How to keep figure active with x_mdialog window open?

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
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: How to keep figure active with x_mdialog window open?

Iza,

Glad that you solved your problem.
In my case, your example works in standalone only (as previous attempts).
However, when I place the code in my larger script with loops and a few graphical windows open, it does not work.
The output vector 'a' remains empty and a warning is issued: " 'Value' property does not exist for this handle. "

Regards,
Rafael

-----Original Message-----
From: users <[hidden email]> On Behalf Of Izabela Wójcik-Grzaba
Sent: Tuesday, July 24, 2018 2:41 PM
To: Users mailing list for Scilab <[hidden email]>
Subject: Re: [Scilab-users] How to keep figure active with x_mdialog window open?

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
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users