how to make a window show up several times in matlab app designer?

Hi,I want to show up one window containing a listbox several times dependent on a number that user entered earlier and that I made a callback for. In other words I want to run a while loop. Is it possible also to write some code including while loop before I refer to another app in the callback function?
I have attached two simple apps to illustrate the problem; but I am not getting the right results, I am supposed to get a red lamp but the color is not changing...tester_flere_vinduer is using app2 in itself

3 Comments

Are you wanting to have a number of different copies show up at the same time, or are you wanting to have it pop up, have the user select, disappear, pop up again, and so on, happening the number of times desired?
When you have a fixed number of executions, it is more common to use a for loop.
@Walter Roberson yes, the second alternative you mentioned ; I want it to pop up, have the user select , disappear , pop up againg happening the number of desired times , :)

Sign in to comment.

Answers (1)

I suggest creating it once, and setting its Visible property to 'off' when you do not need it. When you need it, set Visible 'on' and have the callback that validates selection set the Visible 'off' again after verifying the selection is valid.
for count = 1 : N
app.AppropriateHandleNameHere.Visible = 'on';
waitfor(app.AppropriateHandleNameHere.Visible, 'off');
end

5 Comments

@Walter Roberson Actually I have some procedures in some functions that I want to run before the listbox appears again for the second time for instance.
I attached two simple apps to illustrate the problem, could you have a look on them; I am not getting the desired result; a red lamp
I dont understand what you mean by handlename in your code, could your explain how I get it please?
for count = 1 : N
app.ListBox.Visible = 'on';
waitfor(app.ListBox.Visible, 'off');
end
In app2 you test the Value of the Listbox == 1 but the Value of the Listbox has been configured to character so Listbox == "1" would be needed or else you would need to configure the properties of the listbox to return numeric values.
I do not really recommend using one app to invoke another app. I recommend that you make the listbox part of the first app -- just configure it to start with Visible 'off' and do not turn the Visible 'on' until you have obtained the counter from the user.
@Walter Roberson Why should I not use one app to invoke another?, I feel it is easier..
When you have multiple apps, you have to coordinate between them. You have to have a way to exchange data both ways, and you have to have a way to have one wait for the other to be ready.
Remember that the typical graphic user interface runs to create graphics objects and then returns the handle to a container, after having set up callbacks, and when the user triggers the callbacks, the creation code for the app has already returned -- so the invoking app is already back running and does not inherently have any way to know when the second app has input or results "ready" for the first app.
You can work these situations out, but it is typically notably easier to just use a single app.

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 20 May 2023

Commented:

on 4 Jun 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!