How does seperate script tell compiled GUI its done

1 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2022-5-29
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.
Donny Mott
Donny Mott 2022-5-29
No GPU or Parallel processing. Its just a simple script that I run from the gui and when the script is done the Gui has no idea its done. How can the Gui find out the script is done so that I can tell the user ithe script is done?
Must be a way to send command window text to the app. I tried diary and the script saved a file but it was empty and I am not sure how to tell the app when to read the file if I can get the script side working.

请先登录,再进行评论。

采纳的回答

Jan
Jan 2022-5-29
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 个评论
Donny Mott
Donny Mott 2022-5-30
Thank you for that. Good advice. Still learning. I have not tried to rewrite the original 300 line script to functions yet. But may once I learn more about programming.
Jan
Jan 2022-5-31
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by