OpeningFcn with GUI NOT created by GUIDE
古いコメントを表示
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.
採用された回答
その他の回答 (5 件)
Joseph Cheng
2014 年 7 月 21 日
1 投票
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 日
George Lazaridis
2014 年 7 月 22 日
0 投票
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).
George Lazaridis
2014 年 7 月 22 日
0 投票
7 件のコメント
Robert Cumming
2014 年 7 月 22 日
The delay you have sounds like its the time taken to load the MCR. There is nothing you can do in your m-code to solve this.
Its not a trivial problem to solve - hence why you have to pay for Yairs solution.
George Lazaridis
2014 年 7 月 22 日
Robert Cumming
2014 年 7 月 22 日
Of course its possible - thats what Yair did.
I assume a VS solution would you require loading your GUI as a DLL into the project - and all your VS solution does is to display your splashscreen - which is displayed while the DLL (+MCR) is loaded.
George Lazaridis
2014 年 7 月 22 日
Robert Cumming
2014 年 7 月 22 日
It doesn't require the openingfcn - that is just using it as an example.
It requires any function where you start your code - so put it just before you make your gui visible/interactive.
The creation of your splash screen is in the wrapper - all your doing is deleting it in your m-code.
George Lazaridis
2014 年 7 月 22 日
George Lazaridis
2014 年 7 月 22 日
カテゴリ
ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!