Detect when UIfigure is open

조회 수: 33 (최근 30일)
Rob Campbell
Rob Campbell 2023년 1월 6일
답변: J. Alex Lee 2023년 1월 6일
I have made a GUI with the AppDesigner. It takes about four seconds after launching the last command in constructor has seemingly completed for the GUI to appear. This somewhat on the long side and so I'd like to make a splash screen that disappears once main the GUI has appeared. However, I don't know what event to listen to in order to make this happen. The Visible property, for instance, is 'on' before the figure itself appears.

답변 (2개)

Adam Danz
Adam Danz 2023년 1월 6일
MATLAB currently does not return an indication that rendering is complete but you could use a MATLAB function that requires rendering to be complete for it to execute. In this demo, I use getframe to capture the app figure as soon as it's ready and then the splash screen is deleted.
This is in the app's startup function
fig = figure('Color','r'); % Add your splash screen figure here
getframe(app.UIFigure); % app.UIFigure is the handle to your app figure
close(fig)
Here's an alternative approach to try that would require more work to set up but would be cleaner and more efficient.
  1. Set the visibility of your app components to off from within app designer so that the figure renders quickly but does not initially show any components. If your components are parented to uipanels, then you can just turn off the panel visibility.
  2. Within the startup function, create a spash screen using uiprogressdlg and include the Indeterminate option, then turn visibility on for all components, and finally, close the progress dialog.

J. Alex Lee
J. Alex Lee 2023년 1월 6일
the best i have been able to do is to not use appdesigner itself to create ui components and start the app very bare bones so that the window appears as immediately as possible, then use uiprogressdlg around a manual component creation.
you can still use the appdesigner to lay everything out, and copy the code that gets auto-generated, and wrap that in a function that you can call in the startupfcn,
instead of uiprogressdlg, i have also done apps where i show a uiimage over the entire window to emulate a splash screen, which disappears after the startup fcn has run.
i don't think this really solves the problem of matlab not being able to report when the uifigure element updates are "done" though...

카테고리

Help CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by