OpeningFcn with GUI NOT created by GUIDE
조회 수: 2 (최근 30일)
이전 댓글 표시
Dear all, i have created a GUI without GUIDE and i am wondering how it's possible to call the OpeningFcn function like in GUIs created with GUIDE.
댓글 수: 0
채택된 답변
Robert Cumming
2014년 7월 21일
As joseph said - you dont need to.
One way around it is to create your figure with visible set to off - call your own OpeningFcn - then set visible to on!
댓글 수: 0
추가 답변 (5개)
Joseph Cheng
2014년 7월 21일
Do you need to? whatever you're using to create the GUI (not with GUIDE) is the OpeningFcn portion.
댓글 수: 1
Joseph Cheng
2014년 7월 21일
well it looks like you're compiling it into a standalone exe? then i do not think putting it in the openingfcn equivalent is going to help as its taking 2min for matlab runtime to get everything straight before showing you anything.
http://www.mathworks.com/matlabcentral/answers/92901-how-can-i-show-a-splash-screen-when-the-mcr-is-loading-in-windows-standalone-application-mode is a thread i found that maybe relevant.
If you're not compiling to an executable then here is an example with the little details on why it takes 2 min (actual processing occurring or just displaying a simple GUI?). (come code or description of your startup sequence would have been nice):
function SplashScreen_Main()
fig_hand = figure; %figure handles
fig_size = get(fig_hand ,'Position');
I = imread('logo.tif');
AXES = axes;
imagesc(I),colormap(gray),set(AXES,'Position',[0 0 1 1])
set(fig_hand,'menubar','none');
Process_2minStartup(10)
YPos_offset=-65; %offset in y
%loop to generate popups.
for i=1:5
Type(i)=uicontrol('Style', 'popup',...
'String', '|1|2|3|4|5',...
'Position', [20 340+(i-1)*YPos_offset 100 50],'tag',['TYPE' num2str(i)]);
end
%setting some to enable off;
set(Type(1),'Enable','off');
set(Type(3),'Enable','off');
%disp(Type) %my debuging
%generate pushbutton.
Pbutton=uicontrol('Style', 'pushbutton',...
'String', 'check',...
'Position', [220 340 100 20],...
'Callback', {@check, fig_hand});
delete(AXES)
function Process_2minStartup(seconds)
pause(seconds)
function check(~,~,fig_hand)
TYPE=findobj(fig_hand,'Style','popup') %this is just to see if the popup numbers match what i have above for Type.
popup_tag = get(TYPE,'tag'); %get the tags
popup_enabled = get(TYPE,'Enable'); %get enabled
popup_stuff = get(TYPE,'String'); %get whats inside the pop up boxes
popup_select = get(TYPE,'Value'); %get which item was selected
for ind = 1:length(TYPE)
if strcmp(popup_enabled{ind},'on'); %check which popups are enabled
if strcmp(popup_stuff{ind}(popup_select{ind}),' ') %check if empty
fprintf(2, 'Problem: Empty string in: %s\n', popup_tag{ind});
else
fprintf(1,'Good: Valid string in: %s is %s\n', popup_tag{ind}, popup_stuff{ind}(popup_select{ind}));
end
else
fprintf(1,'Enable Off for Popup: %s\n', popup_tag{ind});
end
end
Pardon the not relevant code but to save some time i used an example i gave earlier today. So depending on whats taking the 2 min move the splash screen above.
George Lazaridis
2014년 7월 22일
댓글 수: 1
Robert Cumming
2014년 7월 22일
what version of matlab are you using? In R2014a you can specify a splashscreen which Matlab will display while the MCR loads (which is most likely to be whats taking the majority of the time).
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!