OpeningFcn with GUI NOT created by GUIDE
2 ビュー (過去 30 日間)
古いコメントを表示
George Lazaridis
2014 年 7 月 21 日
コメント済み: George Lazaridis
2014 年 7 月 22 日
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!