Add new window to OpeningFcn of MATLAB GUI goes to back of main window when running - matlab

I have a Main_window in MATLAB guide. I want open a New_window when I run Main_window, So I add this code in OpeningFcn of Main_window :
New_window();
When I run Main_window, New_window goes to back of Main_window. I want it in front of Main_window after running.
Any help?

This is happening because you are calling New_window before Main_window has finished executing.
Ideas:
You could simply call Main from new instead. I'm guessing that you already tried this and it doesn't work for your application
If you want the user to do something with new_window, then proceed to main_window, you could enable uiwait in the new_window opening fcn to keep it in focus until the user closes it.
Create a script that contains two lines
Main_window;
New_window;
Running that script will start both programs in sequence, and New_window will be on top.
Ultimately, if you want to maximize control, you should write your own gui instead of using GUIDE.

Related

How to run a gui from another gui tab in matlab?

I am unsure of how to call up and run a separate GUI from my main GUI homepage. I am able to open it using uiopen(' ') but I am trying to get it to automatically run it if possible. I've created all of the GUI pages and I have set up the callbacks but I cant get it to work.
every GUI has a guifile.m, so you can just call the name of the 2nd GUI.
for example, assuming you have two GUIs, gui1.{m,fig} and gui2.{m,fig}. In the OnButtonClick even in your gui1.m, you just call gui2 to open up the gui2 window.

How to pause my first MATLAB GUI while the second one is in front

I want to find a solution that pauses the GUI that I created using App Designer in MATLAB.
I mean exactly like uigetfile(), that when you run it you can’t reach the main GUI windows until you close the uigetfile() window.
I need a way to pause my first GUI in the background while my second GUI is in front.
You should set the WindowStyle property of the second figure window to 'modal'. See the documentation for this property.

Tcl/Tk grab a window globally

My Tk application has a main window, when executing, new window arises to show the running progress. I want all the events (mouse, keyboard, etc) are directed to the progress window, so when program is runned, user cannot interact with the main window, and must wait until execution is done and progress window destroyed.
I tried using grab to handle this.
grab set .progress_window
But it doesn't work. The progress window still disappears when mouse clicked somewhere outside it.
grab set -global .progress_window seems work but it block all the other windows running on my computer.
How to solve this problem?
Thank you so much.
You might need this too to keep it on top:
wm transient .progress_window .
Also, see how Tk itself creates modal dialogs.
There are some hoops to go through to get it fully right, e.g.:
https://github.com/tcltk/tk/blob/master/library/dialog.tcl

How to run the code without the GUI

I have a rather long perltk code in my hand and I would like to run the simulation in a batch mode (without using the GUI). e.g. I would like to run it with script like "myprog.pl -b" in stead of setting all the parameters in the GUI and click buttons.
My current method is using a separated XML file for config and the function "after" which means the GUI will pop-out and start the simulation then exit after sometime. It is now working, but I have a question: is there a better way solve this problem? Is that possible to have the GUI shown in the background (so we wont see it) in stead of pop-out?
Change the program so it is accessible from both a graphical and command-line interface. Factor out its real functionality into subroutines.
Run the program in an xvfb so that no window is shown on the main display.
Configure the window manager to always start instances of this program minimised and/or with a 0x0 size.

MATLAB - How do I automatically close the Import Wizard (command window)?

I am invoking the "uiimport" command within a program, opening the Import Wizard to display some data. I would like to be able to automatically close the Wizard within a function (equivalent to "close(gcf)" for a figure), as opposed to having to click "Finish" or "Cancel" or whatever. Is there a way to do this, or should I just find a different way to display the data?
TIA for your help.
I would find a better way to show the data. uiimport is modal, so execution is suspended until it closes, so the script that started it cannot close it.