stop bringing GUI to front
이전 댓글 표시
Hi,
I actually have 2 GUIs. One open in the front and another one running in the background. The GUI in the background shows an axes which displays a text that is rebuilt periodically. Every rebuild brings the GUI to front. How can I turn this off?
채택된 답변
추가 답변 (1개)
Sean de Wolski
2013년 9월 20일
편집: Sean de Wolski
2013년 9월 20일
Hi Adrian,
You have to use low level plotting functionality to set the properties of graphics objects (i.e. the text) that already exist rather than creating new ones.
I did this in an example here for changing the figure settings, you'll need to do the same for text.
If you want a small example, I could create it for you.
More: Example
function changeTextInBackground
%Some strings to cycle through
strings = {'Hello World';...
'Happy Friday';...
'Oktoberfest is nearly here';...
'The Patriots are still 2-0!';...
'And the Ravens aren''t.'};
%Background figure
hFig1 = figure;
set(hFig1,'units','normalized');
plot(1:10);
%We create the text box here, only once
hText = text(5,5,'Initializing...');
%Build the foreground figure
hFig2 = figure;
surf(peaks);
% Timer will change text every second
T = timer('Period',1,... %period
'ExecutionMode','fixedRate',... %{singleShot,fixedRate,fixedSpacing,fixedDelay}
'BusyMode','drop',... %{drop, error, queue}
'TasksToExecute',200,...
'StartDelay',0,...
'TimerFcn',@changeText,...
'StartFcn',[],...
'StopFcn',[],...
'ErrorFcn',[]);
ii = 0; %index for cycling through strings
start(T);
function changeText(~,~)
% increment location
ii = ii+1; %Move the figure
%This is the key line!!! hText already exists, we're just updating
%it
set(hText,'String',strings{ii});
drawnow; %force update
%Reset
if ii == numel(strings)
ii = 0;
end
end
end
댓글 수: 4
Adrian
2013년 9월 20일
Sean de Wolski
2013년 9월 20일
Well you don't want to set it to invisible! You want to change the property that controls what you're seeing. Let me adapt the last example.
Adrian
2013년 9월 20일
Adrian
2013년 9월 20일
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!