How does seperate script tell compiled GUI its done
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Donny Mott
el 28 de Mayo de 2022
Comentada: Jan
el 31 de Mayo de 2022
I have a simple Gui I built in App Designer that allows the user to select a file and fill in some text boxes. These box vaules are saved as variables in a mat file which is saved. The run button in the app calls a external script which loads these values into its workspace. The script then processes the file and can save out between 1 a 16 files. I have not been able to find a way to pass the status of the script back to the app as it saves each of the files. Closest I have came is using a msgbox which pops up a window between each file save. This does not work becasue it happens after the fact and either stays open and the next one stacks on top or I use pause and hold it open for x time then close which slows the process. And at the end I would like it to say done but am unsure how to do that either.
%% Point cloud export
% In this part of the code, the scatterplot is exported.
% Defining output document names
filename = sprintf([output_file_name,'_', num2str(iiii)]);
cd(output)
% Write file
pcloud{1,ii} = PC_Final1;
pcwrite(PC_Final1,filename,'PLYFormat','binary');
cd(input)
ref = []; % suppression of the loaded point cloud
f = msgbox((["Processed File:";output_file_name,'_', num2str(iiii) ' of 16\n']),"Status");
pause(10)
if isvalid(f); delete(f); end
How can I have the msgbox close when the next file is saved and after the last one say done?
6 comentarios
Walter Roberson
el 29 de Mayo de 2022
Unless you are using GPUs or parallel processing, or external processes, then the script does not return to the gui until the script finishes executing. As soon as you get back from the run() the script is finished.
Respuesta aceptada
Jan
el 29 de Mayo de 2022
The solution is trivial: Just add some code to show the progress. Your code was fine and efficient:
app.ProgressField.Value = "Processing PCAP File, Please Wait";
drawnow;
run('TLS_PCAP_script');
app.ProgressField.Value = "Processing Done";
drawnow;
What is your problem with this code? It shows "Please wait" until the script is running and "Done" afterwards.
By the way, using functions instead of scripts is strongly recommended for productive work. Keeping the workspace clean is important.
7 comentarios
Jan
el 31 de Mayo de 2022
Most likely all you need is to start the code by
function yourMFileName
and append an
end
Maybe some inputs and outputs must be defined.
Más respuestas (0)
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!