delete splash screen from background
조회 수: 2(최근 30일)
I am adding a splash screen while my standalone matlab gui loads using the functions
function gui_OpeningFcn(hObject, ~, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to guiTest (see VARARGIN)
% Choose default command line output for guiTest
handles.output = hObject;
% Update handles structure
function initialize_gui(hObject, fig_handle, handles)
splash = imshow(imread('splash.png'),[0,255]);
I am trying to delete the variable splash once the gui loads. I have looked on the mathworks file share site but feel this way is much easier. I just can't figure out how to delete splash once the gui is loaded. I imagine I can create an if statement saying if (edittextbox, 'Visible', 'On') delete(splash) but that hasn't worked yet. Would I place that if statement under the initialize_gui function or underneath the callback function of the editText?
Geoff Hayes 2016년 12월 4일
Tyler - I don't think that adding a splash screen/image to the OpeningFcn of your GUI is the right way to go. From https://www.mathworks.com/help/matlab/creating_guis/initializing-a-guide-gui.html, the opening function is the first callback in every GUIDE code file. It is executed just before the UI is made visible to the user, but after all the components have been created, i.e., after the components' CreateFcn callbacks, if any, have been run. So it seems a little too late at this point to launch the splash image because the GUI is just about ready to be made visible.
You may want to consider creating a separate GUI which just acts as a splash screen. It would show your image (as the splash) and then start a timer (all from within its OpeningFcn). When the timer expires, the second GUI would be launched and when its OpeningFcn is called and is about to finish, it could then find the handle to the first GUI (the splash screen) and close it. Note that you would need to set the HandleVisibility property to On for the first GUI so that you can find it from your second. See https://www.mathworks.com/matlabcentral/answers/146215-pass-data-between-gui-s for an example.